Jogamp
Bug 1214 - NEWT MacOSX: Detect auto-resize of Window when it is larger than screen
authorSven Gothel <sgothel@jausoft.com>
Fri, 25 Sep 2015 07:43:21 +0000 (09:43 +0200)
committerSven Gothel <sgothel@jausoft.com>
Fri, 25 Sep 2015 07:43:21 +0000 (09:43 +0200)
- On OSX (similar to X11) a created window with size > screen
  will get resized to fit screen size implicitly.

- Fix detects insets, position and size after onscreen window creation.

- Patch also merges insets and size change java callback

make/scripts/tests.sh
src/newt/classes/jogamp/newt/WindowImpl.java
src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
src/newt/native/MacWindow.m
src/newt/native/NewtMacWindow.h
src/newt/native/NewtMacWindow.m
src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java [new file with mode: 0644]
src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java

index 357a5f3..50f9cf8 100644 (file)
@@ -189,7 +189,7 @@ function jrun() {
     #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all"
     #D_ARGS="-Djogl.debug.GLArrayData"
     #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window"
-    #D_ARGS="-Dnewt.debug.Window"
+    D_ARGS="-Dnewt.debug.Window"
     #D_ARGS="-Dnewt.debug.Screen"
     #D_ARGS="-Dnewt.test.Screen.disableRandR13"
     #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen"
@@ -424,7 +424,7 @@ function testawtswt() {
 #
 # HiDPI
 #
-#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.TestGearsES2SimpleNEWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
@@ -863,7 +863,7 @@ function testawtswt() {
 #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $*
 #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo $*
 #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo $*
-testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $*
+#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $*
 #testawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtCanvasAWTDemo $*
 
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $*
index 4e33bfd..e005b91 100644 (file)
@@ -4653,7 +4653,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     // Accumulated actions
     //
 
-    /** Triggered by implementation's WM events to update the client-area position, size and maximized flags. */
+    /** Triggered by implementation's WM events to update the client-area position, size and insets. */
+    protected void sizePosInsetsChanged(final boolean defer,
+                                     final int newX, final int newY,
+                                     final int newWidth, final int newHeight,
+                                     final int left, final int right, final int top, final int bottom,
+                                     final boolean force) {
+        sizeChanged(defer, newWidth, newHeight, force);
+        positionChanged(defer, newX, newY);
+        insetsChanged(defer, left, right, top, bottom);
+    }
+
+    /** Triggered by implementation's WM events to update the client-area position, size, insets and maximized flags. */
     protected void sizePosMaxInsetsChanged(final boolean defer,
                                      final int newX, final int newY,
                                      final int newWidth, final int newHeight,
index 2bbcdce..26e5604 100644 (file)
@@ -358,24 +358,26 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
 
     @Override
     protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) {
-        final long handle = getWindowHandle();
-        if( 0 != handle && !isOffscreenInstance ) {
-            final NativeWindow parent = getParent();
-            final boolean useParent = useParent(parent);
-            if( useParent && ( getWidth() != newWidth || getHeight() != newHeight ) ) {
-                final int x=getX(), y=getY();
-                final Point p0S = getLocationOnScreenImpl(x, y, parent, useParent);
-                if(DEBUG_IMPLEMENTATION) {
-                    System.err.println("MacWindow: sizeChanged() parent["+useParent+" "+x+"/"+y+"] "+getX()+"/"+getY()+" "+newWidth+"x"+newHeight+" ->  "+p0S+" screen-client-pos");
+        if(force || getWidth() != newWidth || getHeight() != newHeight) {
+            final long handle = getWindowHandle();
+            if( 0 != handle && !isOffscreenInstance ) {
+                final NativeWindow parent = getParent();
+                final boolean useParent = useParent(parent);
+                if( useParent ) {
+                    final int x=getX(), y=getY();
+                    final Point p0S = getLocationOnScreenImpl(x, y, parent, useParent); // uses parent traversion
+                    if(DEBUG_IMPLEMENTATION) {
+                        System.err.println("MacWindow: sizeChanged() parent["+useParent+" "+x+"/"+y+"] "+getX()+"/"+getY()+" "+newWidth+"x"+newHeight+" ->  "+p0S+" screen-client-pos");
+                    }
+                    OSXUtil.RunOnMainThread(false, false, new Runnable() {
+                        @Override
+                        public void run() {
+                            setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY(), isVisible());
+                        } } );
                 }
-                OSXUtil.RunOnMainThread(false, false, new Runnable() {
-                    @Override
-                    public void run() {
-                        setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY(), isVisible());
-                    } } );
             }
+            superSizeChangedOffThread(defer, newWidth, newHeight, force);
         }
-        superSizeChangedOffThread(defer, newWidth, newHeight, force);
     }
     private void superSizeChangedOffThread(final boolean defer, final int newWidth, final int newHeight, final boolean force) {
         if( defer ) {
@@ -477,7 +479,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
             // no native event (fullscreen, some reparenting)
             positionChanged(false,  x, y);
             updatePixelScaleByWindowHandle(false /* sendEvent */);
-            super.sizeChanged(false, width, height, true);
+            if(isOffscreenInstance) {
+                super.sizeChanged(false, width, height, true);
+            } else {
+                updateSizePosInsets0(getWindowHandle(), false);
+            }
             visibleChanged(false, 0 != ( STATE_MASK_VISIBLE & flags));
             if( hasFocus ) {
                 requestFocusImpl(true);
@@ -532,13 +538,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
     private Point getLocationOnScreenImpl(final int x, final int y, final NativeWindow parent, final boolean useParent) {
         if( !useParent && !isOffscreenInstance && 0 != surfaceHandle) {
             return OSXUtil.GetLocationOnScreen(surfaceHandle, x, y);
+        } else {
+            final Point p = new Point(x, y);
+            if( useParent ) {
+                p.translate( parent.getLocationOnScreen(null) );
+            }
+            return p;
         }
-
-        final Point p = new Point(x, y);
-        if( useParent ) {
-            p.translate( parent.getLocationOnScreen(null) );
-        }
-        return p;
     }
 
     /** Callback for native screen position change event of the client area. */
@@ -797,6 +803,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
     private native void setAlwaysOnTop0(long window, boolean atop);
     /** Must be called on Main-Thread */
     private native void setAlwaysOnBottom0(long window, boolean abottom);
+    private native void updateSizePosInsets0(long window, boolean defer);
     private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y);
     private static native void setPointerIcon0(long windowHandle, long handle);
     private static native void setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible);
index b59e19e..a0164c3 100644 (file)
@@ -1374,6 +1374,26 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContent
 
 /*
  * Class:     jogamp_newt_driver_macosx_WindowDriver
+ * Method:    updateSizePosInsets0
+ * Signature: (JZ)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_updateSizePosInsets0
+  (JNIEnv *env, jobject jthis, jlong window, jboolean defer)
+{
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window);
+
+    DBG_PRINT( "updateSizePosInsets - window: %p, defer %d (START)\n", mWin, (int)defer);
+
+    [mWin updateSizePosInsets: env jwin:jthis defer:defer];
+
+    DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p, defer %d (END)\n", mWin, (int)defer);
+
+    [pool release];
+}
+
+/*
+ * Class:     jogamp_newt_driver_macosx_WindowDriver
  * Method:    setWindowClientTopLeftPointAndSize0
  * Signature: (JIIIIZ)V
  */
index 7dc5c6e..151eb07 100644 (file)
@@ -165,6 +165,7 @@ CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen);
 - (BOOL) isRealized;
 
 - (void) updateInsets: (JNIEnv*) env jwin: (jobject) javaWin;
+- (void) updateSizePosInsets: (JNIEnv*) env jwin: (jobject) javaWin defer: (jboolean)defer;
 - (void) attachToParent: (NSWindow*) parent;
 - (void) detachFromParent: (NSWindow*) parent;
 
index 7b3df39..864dbed 100644 (file)
@@ -179,6 +179,7 @@ static jmethodID requestFocusID = NULL;
 
 static jmethodID insetsChangedID   = NULL;
 static jmethodID sizeChangedID     = NULL;
+static jmethodID sizePosInsetsChangedID = NULL;
 static jmethodID updatePixelScaleID = NULL;
 static jmethodID visibleChangedID = NULL;
 static jmethodID positionChangedID = NULL;
@@ -830,12 +831,14 @@ NS_ENDHANDLER
     updatePixelScaleID = (*env)->GetMethodID(env, clazz, "updatePixelScale", "(ZFF)V");
     visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
     insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V");
+    sizePosInsetsChangedID = (*env)->GetMethodID(env, clazz, "sizePosInsetsChanged", "(ZIIIIIIIIZ)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 && updatePixelScaleID && visibleChangedID && insetsChangedID &&
+    if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && updatePixelScaleID && visibleChangedID && 
+        insetsChangedID && sizePosInsetsChangedID &&
         positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID)
     {
         CKCH_CreateDictionaries();
@@ -948,6 +951,32 @@ NS_ENDHANDLER
     }
 }
 
+- (void) updateSizePosInsets: (JNIEnv*) env jwin: (jobject) javaWin defer: (jboolean)defer
+{
+    // update insets on every window resize for lack of better hook place
+    [self updateInsets: NULL jwin:NULL];
+
+    NSRect frameRect = [self frame];
+    NSRect contentRect = [self contentRectForFrameRect: frameRect];
+
+    DBG_PRINT( "updateSize: [ w %d, h %d ]\n", (jint) contentRect.size.width, (jint) contentRect.size.height);
+
+    NSPoint p0 = { 0, 0 };
+    p0 = [self getLocationOnScreen: p0];
+
+    DBG_PRINT( "updatePos: [ x %d, y %d ]\n", (jint) p0.x, (jint) p0.y);
+
+    if( NULL != env && NULL != javaWin ) {
+        (*env)->CallVoidMethod(env, javaWin, sizePosInsetsChangedID, defer,
+                               (jint) p0.x, (jint) p0.y,
+                               (jint) contentRect.size.width, (jint) contentRect.size.height,
+                               cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3],
+                               JNI_FALSE // force
+                              );
+    }
+}
+
+
 - (void) attachToParent: (NSWindow*) parent
 {
     DBG_PRINT( "attachToParent.1\n");
@@ -1198,15 +1227,7 @@ NS_ENDHANDLER
         javaWindowObject = [newtView getJavaWindowObject];
     }
     if( NULL != javaWindowObject ) {
-        // update insets on every window resize for lack of better hook place
-        [self updateInsets: env jwin:javaWindowObject];
-
-        NSRect frameRect = [self frame];
-        NSRect contentRect = [self contentRectForFrameRect: frameRect];
-
-        (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_TRUE, // defer 
-                               (jint) contentRect.size.width,
-                               (jint) contentRect.size.height, JNI_FALSE);
+        [self updateSizePosInsets: env jwin: javaWindowObject defer:JNI_TRUE];
     }
     // detaching thread not required - daemon
     // NewtCommon_ReleaseJNIEnv(shallBeDetached);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LineSquareXDemoES2.java
new file mode 100644 (file)
index 0000000..2169b93
--- /dev/null
@@ -0,0 +1,189 @@
+/**
+ * Copyright (C) 2015 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 com.jogamp.opengl.GL;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLAutoDrawable;
+import com.jogamp.opengl.GLEventListener;
+import com.jogamp.opengl.GLUniformData;
+import com.jogamp.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 LineSquareXDemoES2 implements GLEventListener {
+
+    private boolean multisample, clearBuffers;
+    private final ShaderState st;
+    private final PMVMatrix pmvMatrix;
+    private ShaderProgram sp0;
+    private GLUniformData pmvMatrixUniform;
+    private ImmModeSink immModeSink;
+
+    public LineSquareXDemoES2(final boolean multisample) {
+        this.multisample = multisample;
+        this.clearBuffers = true;
+        st = new ShaderState();
+        st.setVerbose(true);
+        pmvMatrix = new PMVMatrix();
+    }
+
+    public void setClearBuffers(final boolean v) { clearBuffers = v; }
+
+    public void init(final GLAutoDrawable glad) {
+        final GL2ES2 gl = glad.getGL().getGL2ES2();
+
+        System.err.println();
+        System.err.println("req. msaa: "+multisample);
+        System.err.println("Requested: " + glad.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities());
+        multisample = multisample && glad.getChosenGLCapabilities().getNumSamples() > 0 ;
+        System.err.println("Chosen   : " + glad.getChosenGLCapabilities());
+        System.err.println("has  msaa: "+multisample);
+        System.err.println();
+
+        final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LineSquareXDemoES2.class, "shader",
+                "shader/bin", "mgl_default_xxx", true);
+        final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, LineSquareXDemoES2.class, "shader",
+                "shader/bin", "mgl_default_xxx", true);
+        vp0.defaultShaderCustomization(gl, true, true);
+        fp0.defaultShaderCustomization(gl, true, true);
+
+        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);
+
+        final float c = 0f;
+        final float eX = 0.5f;
+        final float eH = 0.98f;
+        final float e2 = 1f;
+
+        // Using predef array names, see
+        //    GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex);
+        immModeSink = ImmModeSink.createGLSL(20*2,
+                                              3, GL.GL_FLOAT,  // vertex
+                                              4, GL.GL_FLOAT,  // color
+                                              0, GL.GL_FLOAT,  // normal
+                                              0, GL.GL_FLOAT,  // texCoords
+                                              GL.GL_STATIC_DRAW, st);
+        immModeSink.glBegin(GL.GL_LINES);
+
+        // Rectangle
+        immModeSink.glVertex3f(-eX, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-eX,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-eX,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eX,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eX,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eX, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eX, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-eX, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+
+        // Square
+        immModeSink.glVertex3f(-eH, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-eH,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-eH,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eH,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eH,  eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eH, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( eH, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-eH, -eH, 0f); immModeSink.glColor4f( c, c, c, c );
+
+        // X
+        immModeSink.glVertex3f(-e2, -e2, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( e2,  e2, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f(-e2,  e2, 0f); immModeSink.glColor4f( c, c, c, c );
+        immModeSink.glVertex3f( e2, -e2, 0f); immModeSink.glColor4f( c, c, c, c );
+
+        immModeSink.glEnd(gl, false);
+
+        st.useProgram(gl, false);
+    }
+
+    public void dispose(final GLAutoDrawable glad) {
+        final GL2ES2 gl = glad.getGL().getGL2ES2();
+        immModeSink.destroy(gl);
+        immModeSink = null;
+        st.destroy(gl);
+    }
+
+    public void display(final GLAutoDrawable glad) {
+        final GL2ES2 gl = glad.getGL().getGL2ES2();
+        if (multisample) {
+            gl.glEnable(GL.GL_MULTISAMPLE);
+        }
+        if( clearBuffers ) {
+            final float c = 0.9f;
+            gl.glClearColor(c, c, c, 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(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
+        System.err.println("reshape ..");
+        final GL2ES2 gl = glad.getGL().getGL2ES2();
+        pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+        pmvMatrix.glLoadIdentity();
+        final float left, right, bottom, top;
+        if( height > width ) {
+            final float a = (float)height / (float)width;
+            left = -1.0f;
+            right = 1.0f;
+            bottom = -a;
+            top = a;
+        } else {
+            final float a = (float)width / (float)height;
+            left = -a;
+            right = a;
+            bottom = -1.0f;
+            top = 1.0f;
+        }
+        // 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.glOrthof(left, right, top, bottom, 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(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {
+    }
+}
index ac8ceb5..4e31804 100644 (file)
@@ -47,7 +47,7 @@ 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 com.jogamp.opengl.test.junit.jogl.demos.es2.LineSquareXDemoES2;
 import com.jogamp.nativewindow.NativeWindowFactory;
 import com.jogamp.nativewindow.ScalableSurface;
 import com.jogamp.nativewindow.util.Dimension;
@@ -100,6 +100,7 @@ public class TestGearsES2NEWT extends UITestCase {
     static boolean forceES3 = false;
     static boolean forceGL3 = false;
     static boolean forceGL2 = false;
+    static boolean demo2 = false;
     static boolean manualTest = false;
     static boolean exclusiveContext = false;
     static boolean useAnimator = true;
@@ -140,9 +141,16 @@ public class TestGearsES2NEWT extends UITestCase {
         glWindow.setPointerVisible(mouseVisible);
         glWindow.confinePointer(mouseConfined);
 
-        final GearsES2 demo = new GearsES2(swapInterval);
-        demo.setUseMappedBuffers(useMappedBuffers);
-        demo.setValidateBuffers(true);
+        final GLEventListener demo;
+        if( demo2 ) {
+            final LineSquareXDemoES2 demo2 = new LineSquareXDemoES2(false);
+            demo = demo2;
+        } else {
+            final GearsES2 gearsES2 = new GearsES2(swapInterval);
+            gearsES2.setUseMappedBuffers(useMappedBuffers);
+            gearsES2.setValidateBuffers(true);
+            demo = gearsES2;
+        }
         glWindow.addGLEventListener(demo);
 
         final SnapshotGLEventListener snap = new SnapshotGLEventListener();
@@ -466,6 +474,8 @@ public class TestGearsES2NEWT extends UITestCase {
                 sysExit = SysExit.valueOf(args[i]);
             } else if(args[i].equals("-manual")) {
                 manualTest = true;
+            } else if(args[i].equals("-demo2")) {
+                demo2 = true;
             }
         }
         wsize = new Dimension(w, h);
http://JogAmp.org git info: FAQ, tutorial and man pages.