summaryrefslogtreecommitdiffstats
path: root/src/test-native/bug1398
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-02-21 15:03:42 +0100
committerSven Gothel <[email protected]>2020-02-21 15:03:42 +0100
commitf4f92cdc0eb89c62070a865601527097e6d5cc72 (patch)
treeed22c616191ca569fbcf31b3c8418fb225522b13 /src/test-native/bug1398
parent4fad4869d4a929739c830f6ce3ac171d8dd5427a (diff)
Bug 1398: Fixing native test allowing its execution using JOGL 2.3.2 and latest tip using XCode 11
Changes to test - Using own 'NSApplicationMain' entry to avoid the 'missing Info.plist' message! - Configurable CLASSPATH and LIBPATH at compile time. Note that the java.library.path is now hardcoded as well. - Don't close stderr in test, just fflush - Don't close the JVM after launch via 'die(env)', let it run. - Java: Add GLEventListener RedSquareES2 to see something in action @ 30fps - Java: GLCanvase visible bounds
Diffstat (limited to 'src/test-native/bug1398')
-rw-r--r--src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c91
-rw-r--r--src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java6
-rw-r--r--src/test-native/bug1398/RedSquareES2.java274
-rwxr-xr-xsrc/test-native/bug1398/make-bug1398.sh24
-rw-r--r--src/test-native/bug1398/run-bug1398.sh16
-rw-r--r--src/test-native/bug1398/shader/RedSquareShader.fp16
-rw-r--r--src/test-native/bug1398/shader/RedSquareShader.vp18
-rw-r--r--src/test-native/bug1398/shader/RedSquareShader2.fp16
-rw-r--r--src/test-native/bug1398/test1398-jogamp232-01.log66
-rw-r--r--src/test-native/bug1398/test1398-jogamp240rc-01.log59
10 files changed, 575 insertions, 11 deletions
diff --git a/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c b/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c
index 08dd7d7ac..8fe51f97e 100644
--- a/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c
+++ b/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c
@@ -35,6 +35,13 @@ void *create_vm(const char *jvm_lib_path)
return sym;
}
+#ifndef CLASSPATH
+#define CLASSPATH ".:/Users/jogamp/projects/JogAmp/gluegen/build/gluegen-rt.jar:/Users/jogamp/projects/JogAmp/jogl/build/jar/jogl-all.jar"
+#endif
+#ifndef LIBPATH
+#define LIBPATH "/Users/jogamp/projects/JogAmp/gluegen/build/obj:/Users/jogamp/projects/JogAmp/jogl/build/lib"
+#endif
+
static void *launchJava(void *ptr)
{
int k = 0;
@@ -49,17 +56,25 @@ static void *launchJava(void *ptr)
// JDK > 1.5
JavaVMInitArgs vm_args;
- vm_args.nOptions = 3;
+ TRACE("launchJava.1.1%s", "");
+ vm_args.nOptions = 7;
JavaVMOption options[vm_args.nOptions];
- options[0].optionString = "-Djava.class.path=.:../../../gluegen/build/gluegen-rt.jar:../../build/jar/jogl-all.jar";
-// options[1].optionString = "-Djava.library.path=lib";
- options[1].optionString = "-Dnativewindow.debug=all";
- options[2].optionString = "-Djogl.debug=all";
+ options[0].optionString = "-Djava.class.path="CLASSPATH;
+ options[1].optionString = "-Djava.library.path="LIBPATH;
+ options[2].optionString = "-DNjogamp.debug=all";
+ options[3].optionString = "-DNjogamp.debug.NativeLibrary=true";
+ options[4].optionString = "-DNjogamp.debug.JNILibLoader=true";
+ options[5].optionString = "-DNnativewindow.debug=all";
+ options[6].optionString = "-DNjogl.debug=all";
vm_args.version = JNI_VERSION_1_4;
vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_TRUE;
+ TRACE("launchJava.1.2%s", "");
+ TRACE(".. using CLASSPATH %s", CLASSPATH);
+ TRACE(".. using LIBPATH %s", LIBPATH);
+
/* Create the Java VM */
CREATEVM *CreateVM = create_vm((char *)ptr);
TRACE("CreateVM:%lx env:%lx vm_args:%lx", (long unsigned int)CreateVM, (long unsigned int)&env, (long unsigned int)&vm_args);
@@ -71,34 +86,40 @@ static void *launchJava(void *ptr)
TRACE("VM Created%s", "");
}
+ TRACE("launchJava.1.3%s", "");
cls = (*env)->FindClass(env, "Bug1398macOSContextOpsOnMainThread");
ex = (*env)->ExceptionOccurred(env);
if (ex) {
die(env);
}
+ TRACE("launchJava.1.4%s", "");
mid = (*env)->GetMethodID(env, cls, "<init>", "()V");
if (mid == NULL)
goto destroy;
+ TRACE("launchJava.1.5%s", "");
gui = (*env)->NewObject(env, cls, mid);
TRACE("Just passed NewObject()...%s", "");
+
destroy:
if ((*env)->ExceptionOccurred(env)) {
// handle exception
+ TRACE("Exception occured...%s", "");
}
if (err)
- fclose(err);
+ fflush(err);
if (jvm_lib) {
dlclose(jvm_lib);
jvm_lib = NULL;
}
- die(env);
+ // die(env);
+ TRACE("launchJava.1.X%s", "");
return 0;
}
@@ -158,6 +179,7 @@ void create_jvm_thread(const char *jvm_lib_path)
}
}
+ TRACE("create_jvm_thread.1.1%s", "");
pthread_attr_t thread_attr;
pthread_attr_init(&thread_attr);
pthread_attr_setscope(&thread_attr, PTHREAD_SCOPE_SYSTEM);
@@ -165,13 +187,17 @@ void create_jvm_thread(const char *jvm_lib_path)
if (stack_size > 0) {
pthread_attr_setstacksize(&thread_attr, stack_size);
}
+ TRACE("create_jvm_thread.1.2%s", "");
pthread_create(&vmthread, &thread_attr, launchJava, (void *)jvm_lib_path);
pthread_attr_destroy(&thread_attr);
+ TRACE("create_jvm_thread.1.X%s", "");
}
static AppDelegate* _appDelegate;
+#if 0
+
int main(int argc, const char *argv[])
{
err = stderr;
@@ -183,19 +209,70 @@ int main(int argc, const char *argv[])
TRACE("Usage: Bug1398macOSContextOpsOnMainThread %s", "[libjli.dylib path]");
exit(1);
}
+ TRACE("main.1%s", "");
@autoreleasepool
{
+ TRACE("main.1.1%s", "");
_appDelegate = [AppDelegate new];
+ TRACE("main.1.2%s", "");
[NSApplication sharedApplication];
+ TRACE("main.1.3%s", "");
[NSApp activateIgnoringOtherApps:YES];
[NSApp setDelegate:_appDelegate];
+ TRACE("main.1.5%s", "");
create_jvm_thread(argv[1]);
+ TRACE("main.1.6%s", "");
return NSApplicationMain(argc, (const char **)argv);
+ TRACE("main.1.X%s", "");
}
}
+#else
+
+int NSApplicationMain(int argc, const char *argv[]) {
+ // [NSApplication sharedApplication];
+ // [NSBundle loadNibNamed:@"myMain" owner:NSApp];
+ // [NSApp run];
+
+ err = stderr;
+
+ for (int k = 1; k < argc; k++) {
+ TRACE("argv[%d]:%s", k, argv[k]);
+ }
+ if (argc < 2) {
+ TRACE("Usage: Bug1398macOSContextOpsOnMainThread %s", "[libjli.dylib path]");
+ exit(1);
+ }
+ TRACE("main.1%s", "");
+ @autoreleasepool
+ {
+ TRACE("main.1.1%s", "");
+ _appDelegate = [AppDelegate new];
+ TRACE("main.1.2%s", "");
+ [NSApplication sharedApplication];
+ TRACE("main.1.3%s", "");
+ [NSApp activateIgnoringOtherApps:YES];
+ [NSApp setDelegate:_appDelegate];
+ TRACE("main.1.5%s", "");
+
+ create_jvm_thread(argv[1]);
+ TRACE("main.1.6%s", "");
+
+ [NSApp run];
+ // return NSApplicationMain(argc, (const char **)argv);
+ TRACE("main.1.X%s", "");
+ }
+ return 0;
+}
+
+int main(int argc, const char *argv[])
+{
+ return NSApplicationMain(argc, (const char **)argv);
+}
+
+#endif
@interface AppDelegate ()
diff --git a/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java b/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java
index 82578acbb..65b3d3f59 100644
--- a/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java
+++ b/src/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java
@@ -43,7 +43,9 @@ public class Bug1398macOSContextOpsOnMainThread extends JFrame implements GLEven
System.out.println("w:" + dm.getWidth() + " h:" + dm.getHeight() + " rr:" + dm.getRefreshRate() + " bits:" + dm.getBitDepth() + " dim.w:" + dim.width + " dim.h:" + dim.height);
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
canvas = new GLCanvas(caps);
- canvas.setBounds(0, 0, 1, 1);
+ canvas.addGLEventListener(new RedSquareES2());
+ // canvas.setBounds(0, 0, 1, 1);
+ canvas.setBounds(0, 0, 800, 600);
JPanel panel = new JPanel();
panel.setLayout(null);
@@ -69,7 +71,7 @@ public class Bug1398macOSContextOpsOnMainThread extends JFrame implements GLEven
setLocation(x, y);
setVisible(true);
- final FPSAnimator animator = new FPSAnimator(canvas, 5, true);
+ final FPSAnimator animator = new FPSAnimator(canvas, 30, true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
diff --git a/src/test-native/bug1398/RedSquareES2.java b/src/test-native/bug1398/RedSquareES2.java
new file mode 100644
index 000000000..86de51701
--- /dev/null
+++ b/src/test-native/bug1398/RedSquareES2.java
@@ -0,0 +1,274 @@
+/**
+ * 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.demos.es2;
+
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+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 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;
+
+public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRendererListener {
+ private ShaderState st;
+ private PMVMatrix pmvMatrix;
+ private GLUniformData pmvMatrixUniform;
+ private GLArrayDataServer vertices ;
+ private GLArrayDataServer colors ;
+ private long t0;
+ private int swapInterval = 0;
+ private float aspect = 1.0f;
+ private boolean doRotate = true;
+ private boolean verbose = true;
+ private boolean clearBuffers = true;
+ private TileRendererBase tileRendererInUse = null;
+ private boolean doRotateBeforePrinting;
+
+ public RedSquareES2(final int swapInterval) {
+ this.swapInterval = swapInterval;
+ }
+
+ public RedSquareES2() {
+ this.swapInterval = 1;
+ }
+
+ @Override
+ public void addTileRendererNotify(final TileRendererBase tr) {
+ tileRendererInUse = tr;
+ doRotateBeforePrinting = doRotate;
+ setDoRotation(false);
+ }
+ @Override
+ public void removeTileRendererNotify(final TileRendererBase tr) {
+ tileRendererInUse = null;
+ setDoRotation(doRotateBeforePrinting);
+ }
+ @Override
+ public void startTileRendering(final TileRendererBase tr) {
+ System.err.println("RedSquareES2.startTileRendering: "+tr);
+ }
+ @Override
+ public void endTileRendering(final TileRendererBase tr) {
+ System.err.println("RedSquareES2.endTileRendering: "+tr);
+ }
+
+ public void setAspect(final float aspect) { this.aspect = aspect; }
+ public void setDoRotation(final boolean rotate) { this.doRotate = rotate; }
+ public void setClearBuffers(final boolean v) { clearBuffers = v; }
+ public void setVerbose(final boolean v) { verbose = v; }
+
+ @Override
+ public void init(final GLAutoDrawable glad) {
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" RedSquareES2.init: tileRendererInUse "+tileRendererInUse);
+ }
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+
+ if(verbose) {
+ System.err.println("RedSquareES2 init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + glad.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;
+ }
+ st = new ShaderState();
+ st.setVerbose(true);
+ final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader",
+ "shader/bin", "RedSquareShader", true);
+ final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader",
+ "shader/bin", "RedSquareShader", true);
+ vp0.defaultShaderCustomization(gl, true, true);
+ fp0.defaultShaderCustomization(gl, true, true);
+ final ShaderProgram sp0 = new ShaderProgram();
+ sp0.add(gl, vp0, System.err);
+ sp0.add(gl, fp0, System.err);
+ st.attachShaderProgram(gl, sp0, true);
+
+ // setup mgl_PMVMatrix
+ pmvMatrix = new PMVMatrix();
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+ st.ownUniform(pmvMatrixUniform);
+ st.uniform(gl, pmvMatrixUniform);
+
+ // Allocate Vertex Array
+ vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ vertices.putf(-2); vertices.putf( 2); vertices.putf( 0);
+ vertices.putf( 2); vertices.putf( 2); vertices.putf( 0);
+ vertices.putf(-2); vertices.putf(-2); vertices.putf( 0);
+ vertices.putf( 2); vertices.putf(-2); vertices.putf( 0);
+ vertices.seal(gl, true);
+ st.ownAttribute(vertices, true);
+ vertices.enableBuffer(gl, false);
+
+ // Allocate Color Array
+ colors= GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1);
+ colors.putf(0); colors.putf(0); colors.putf(1); colors.putf(1);
+ colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1);
+ colors.putf(1); colors.putf(0); colors.putf(0); colors.putf(1);
+ colors.seal(gl, true);
+ st.ownAttribute(colors, true);
+ colors.enableBuffer(gl, false);
+
+ // OpenGL Render Settings
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ st.useProgram(gl, false);
+
+ t0 = System.currentTimeMillis();
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" RedSquareES2.init FIN");
+ }
+ }
+
+ @Override
+ public void display(final GLAutoDrawable glad) {
+ final long t1 = System.currentTimeMillis();
+
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ if( clearBuffers ) {
+ if( null != tileRendererInUse ) {
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
+ } else {
+ gl.glClearColor(0, 0, 0, 0);
+ }
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ }
+ if( !gl.hasGLSL() ) {
+ return;
+ }
+ st.useProgram(gl, true);
+ // One rotation every four seconds
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, -10);
+ if(doRotate) {
+ final float ang = ((t1 - t0) * 360.0F) / 4000.0F;
+ pmvMatrix.glRotatef(ang, 0, 0, 1);
+ pmvMatrix.glRotatef(ang, 0, 1, 0);
+ }
+ st.uniform(gl, pmvMatrixUniform);
+
+ // Draw a square
+ vertices.enableBuffer(gl, true);
+ colors.enableBuffer(gl, true);
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+ vertices.enableBuffer(gl, false);
+ colors.enableBuffer(gl, false);
+ st.useProgram(gl, false);
+ }
+
+ @Override
+ public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ gl.setSwapInterval(swapInterval);
+ reshapeImpl(gl, x, y, width, height, width, height);
+ }
+
+ @Override
+ public void reshapeTile(final TileRendererBase tr,
+ final int tileX, final int tileY, final int tileWidth, final int tileHeight,
+ final int imageWidth, final int imageHeight) {
+ final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2();
+ gl.setSwapInterval(0);
+ reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
+ }
+
+ void reshapeImpl(final GL2ES2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) {
+ if(verbose) {
+ 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;
+ }
+
+ st.useProgram(gl, true);
+ // Set location in front of camera
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+
+ // compute projection parameters 'normal' perspective
+ final float fovy=45f;
+ final float aspect2 = ( (float) imageWidth / (float) imageHeight ) / aspect;
+ final float zNear=1f;
+ final float zFar=100f;
+
+ // compute projection parameters 'normal' frustum
+ final float top=(float)Math.tan(fovy*((float)Math.PI)/360.0f)*zNear;
+ final float bottom=-1.0f*top;
+ final float left=aspect2*bottom;
+ final float right=aspect2*top;
+ 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;
+
+ pmvMatrix.glFrustumf(l, r, b, t, zNear, zFar);
+ //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+
+ System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN");
+ }
+
+ @Override
+ public void dispose(final GLAutoDrawable glad) {
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" RedSquareES2.dispose: tileRendererInUse "+tileRendererInUse);
+ }
+ final GL2ES2 gl = glad.getGL().getGL2ES2();
+ if( !gl.hasGLSL() ) {
+ return;
+ }
+ st.destroy(gl);
+ st = null;
+ pmvMatrix = null;
+ if(verbose) {
+ System.err.println(Thread.currentThread()+" RedSquareES2.dispose FIN");
+ }
+ }
+}
diff --git a/src/test-native/bug1398/make-bug1398.sh b/src/test-native/bug1398/make-bug1398.sh
index cc6ec6800..d410f7066 100755
--- a/src/test-native/bug1398/make-bug1398.sh
+++ b/src/test-native/bug1398/make-bug1398.sh
@@ -2,5 +2,25 @@
set -x
-gcc -x objective-c -framework Cocoa -o Bug1398macOSContextOpsOnMainThread Bug1398macOSContextOpsOnMainThread.c \
- && javac -source 1.8 -target 1.8 -classpath ../../../gluegen/build/gluegen-rt.jar:../../build/jar/jogl-all.jar Bug1398macOSContextOpsOnMainThread.java
+USE_232=1
+ok=0
+
+if [ $USE_232 -eq 0 ] ; then
+ xcrun clang -x objective-c -framework Cocoa \
+ -DCLASSPATH="\".:/Users/jogamp/projects/JogAmp/gluegen/build/gluegen-rt.jar:/Users/jogamp/projects/JogAmp/jogl/build/jar/jogl-all.jar\"" \
+ -DLIBPATH="\"/Users/jogamp/projects/JogAmp/gluegen/build/obj:/Users/jogamp/projects/JogAmp/jogl/build/lib\"" \
+ -o Bug1398macOSContextOpsOnMainThread Bug1398macOSContextOpsOnMainThread.c \
+ && ok=1
+else
+ xcrun clang -x objective-c -framework Cocoa \
+ -DCLASSPATH="\".:/Users/jogamp/projects/JogAmp/builds/v2.3.2/jogamp-all-platforms/jar/gluegen-rt.jar:/Users/jogamp/projects/JogAmp/builds/v2.3.2/jogamp-all-platforms/jar/jogl-all.jar\"" \
+ -DLIBPATH="\"/Users/jogamp/projects/JogAmp/builds/v2.3.2/jogamp-all-platforms/lib/macosx-universal\"" \
+ -o Bug1398macOSContextOpsOnMainThread Bug1398macOSContextOpsOnMainThread.c \
+ && ok=1
+fi
+
+if [ $ok -eq 1 ] ; then
+ javac -source 1.8 -target 1.8 -classpath ../../../../gluegen/build/gluegen-rt.jar:../../../build/jar/jogl-all.jar RedSquareES2.java Bug1398macOSContextOpsOnMainThread.java
+fi
+
+# ./Bug1398macOSContextOpsOnMainThread /Users/jogamp/projects/JogAmp/gluegen/build/obj:/Users/jogamp/projects/JogAmp/jogl/build/lib/lib
diff --git a/src/test-native/bug1398/run-bug1398.sh b/src/test-native/bug1398/run-bug1398.sh
new file mode 100644
index 000000000..b4252bbdd
--- /dev/null
+++ b/src/test-native/bug1398/run-bug1398.sh
@@ -0,0 +1,16 @@
+#! /bin/bash
+
+# export LD_LIBRARY_PATH=/Users/jogamp/projects/JogAmp/gluegen/build/obj:/Users/jogamp/projects/JogAmp/jogl/build/lib
+# export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
+
+#rm -rf natives
+#mkdir -p natives/macosx-universal
+#cp -av /Users/jogamp/projects/JogAmp/gluegen/build/obj/libgluegen_rt.so natives/macosx-universal/
+#cp -av natives/macosx-universal/libgluegen_rt.so natives/macosx-universal/libgluegen_rt.dylib
+#cp -av /Users/jogamp/projects/JogAmp/jogl/build/lib/*dylib natives/macosx-universal/
+
+# ./Bug1398macOSContextOpsOnMainThread /Users/jogamp/projects/JogAmp/gluegen/build/obj:/Users/jogamp/projects/JogAmp/jogl/build/lib/lib
+# ./Bug1398macOSContextOpsOnMainThread /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre/lib/server/libjvm.dylib
+
+./Bug1398macOSContextOpsOnMainThread /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/MacOS/libjli.dylib
+# ./Bug1398macOSContextOpsOnMainThread /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/MacOS/libjli.dylib
diff --git a/src/test-native/bug1398/shader/RedSquareShader.fp b/src/test-native/bug1398/shader/RedSquareShader.fp
new file mode 100644
index 000000000..60b92401e
--- /dev/null
+++ b/src/test-native/bug1398/shader/RedSquareShader.fp
@@ -0,0 +1,16 @@
+// Copyright 2010 JogAmp Community. All rights reserved.
+
+#if __VERSION__ >= 130
+ #define varying in
+ out vec4 mgl_FragColor;
+#else
+ #define mgl_FragColor gl_FragColor
+#endif
+
+varying vec4 frontColor;
+
+void main (void)
+{
+ mgl_FragColor = frontColor;
+}
+
diff --git a/src/test-native/bug1398/shader/RedSquareShader.vp b/src/test-native/bug1398/shader/RedSquareShader.vp
new file mode 100644
index 000000000..9283dd7bd
--- /dev/null
+++ b/src/test-native/bug1398/shader/RedSquareShader.vp
@@ -0,0 +1,18 @@
+// Copyright 2010 JogAmp Community. All rights reserved.
+
+#if __VERSION__ >= 130
+ #define attribute in
+ #define varying out
+#endif
+
+uniform mat4 mgl_PMVMatrix[2];
+attribute vec4 mgl_Vertex;
+attribute vec4 mgl_Color;
+varying vec4 frontColor;
+
+void main(void)
+{
+ frontColor=mgl_Color;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
+
diff --git a/src/test-native/bug1398/shader/RedSquareShader2.fp b/src/test-native/bug1398/shader/RedSquareShader2.fp
new file mode 100644
index 000000000..25a2df2d7
--- /dev/null
+++ b/src/test-native/bug1398/shader/RedSquareShader2.fp
@@ -0,0 +1,16 @@
+// Copyright 2010 JogAmp Community. All rights reserved.
+
+#if __VERSION__ >= 130
+ #define varying in
+ out vec4 mgl_FragColor;
+#else
+ #define mgl_FragColor gl_FragColor
+#endif
+
+varying vec4 frontColor;
+
+void main (void)
+{
+ mgl_FragColor = vec4(0.0, frontColor.g, frontColor.b, 1.0);
+}
+
diff --git a/src/test-native/bug1398/test1398-jogamp232-01.log b/src/test-native/bug1398/test1398-jogamp232-01.log
new file mode 100644
index 000000000..bfc11684a
--- /dev/null
+++ b/src/test-native/bug1398/test1398-jogamp232-01.log
@@ -0,0 +1,66 @@
++ ./Bug1398macOSContextOpsOnMainThread /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/MacOS/libjli.dylib
+Bug1398macOSContextOpsOnMainThread.c:242:NSApplicationMain(): argv[1]:/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/MacOS/libjli.dylib
+Bug1398macOSContextOpsOnMainThread.c:248:NSApplicationMain(): main.1
+Bug1398macOSContextOpsOnMainThread.c:251:NSApplicationMain(): main.1.1
+2020-02-19 21:36:02.797 Bug1398macOSContextOpsOnMainThread[1710:65756] init
+Bug1398macOSContextOpsOnMainThread.c:253:NSApplicationMain(): main.1.2
+Bug1398macOSContextOpsOnMainThread.c:255:NSApplicationMain(): main.1.3
+Bug1398macOSContextOpsOnMainThread.c:258:NSApplicationMain(): main.1.5
+Bug1398macOSContextOpsOnMainThread.c:182:create_jvm_thread(): create_jvm_thread.1.1
+Bug1398macOSContextOpsOnMainThread.c:190:create_jvm_thread(): create_jvm_thread.1.2
+Bug1398macOSContextOpsOnMainThread.c:194:create_jvm_thread(): create_jvm_thread.1.X
+Bug1398macOSContextOpsOnMainThread.c:261:NSApplicationMain(): main.1.6
+Bug1398macOSContextOpsOnMainThread.c:59:launchJava(): launchJava.1.1
+Bug1398macOSContextOpsOnMainThread.c:74:launchJava(): launchJava.1.2
+Bug1398macOSContextOpsOnMainThread.c:75:launchJava(): .. using CLASSPATH .:/Users/jogamp/projects/JogAmp/builds/v2.3.2/jogamp-all-platforms/jar/gluegen-rt.jar:/Users/jogamp/projects/JogAmp/builds/v2.3.2/jogamp-all-platforms/jar/jogl-all.jar
+Bug1398macOSContextOpsOnMainThread.c:76:launchJava(): .. using LIBPATH /Users/jogamp/projects/JogAmp/builds/v2.3.2/jogamp-all-platforms/lib/macosx-universal
+Bug1398macOSContextOpsOnMainThread.c:30:create_vm(): Found libjli.dylib
+Bug1398macOSContextOpsOnMainThread.c:80:launchJava(): CreateVM:104c47b80 env:70000bb98da8 vm_args:70000bb98d68
+2020-02-19 21:36:02.934 Bug1398macOSContextOpsOnMainThread[1710:65756] App starting...
+Bug1398macOSContextOpsOnMainThread.c:86:launchJava(): VM Created
+Bug1398macOSContextOpsOnMainThread.c:89:launchJava(): launchJava.1.3
+2020-02-19 21:36:04.091 Bug1398macOSContextOpsOnMainThread[1710:65801] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
+ 0 AppKit 0x00007fff2c051575 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
+ 1 AppKit 0x00007fff2c038ed5 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
+ 2 AppKit 0x00007fff2c038947 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
+ 3 libnativewindow_macosx.jnilib 0x00000001099203fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
+ 4 ??? 0x000000010ae94667 0x0 + 4478027367
+)
+Bug1398macOSContextOpsOnMainThread.c:96:launchJava(): launchJava.1.4
+Bug1398macOSContextOpsOnMainThread.c:101:launchJava(): launchJava.1.5
+Java version: 1.8 (1.8.0_192)
+classloader:sun.misc.Launcher$AppClassLoader@764c12b6
+OS: Mac OS X 10.15.2 x86_64
+w:1920 h:1080 rr:60 bits:32 dim.w:800 dim.h:600
+gc.bounds: java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
+dim: java.awt.Dimension[width=1920,height=1080]
+Bug1398macOSContextOpsOnMainThread.c:103:launchJava(): Just passed NewObject()...
+Bug1398macOSContextOpsOnMainThread.c:122:launchJava(): launchJava.1.X
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.init: tileRendererInUse null
+RedSquareES2 init on Thread[AWT-EventQueue-0,6,main]
+Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]]
+INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
+Swap Interval 0
+GL Profile GLProfile[GL2/GL2.hw]
+GL Version 2.1 (Compat profile, arb, compat[], FBO, hardware) - 2.1 INTEL-14.3.9 [GL 2.1.0, vendor 14.3.9 (INTEL-14.3.9)]
+Quirks [NoOffscreenBitmap, GL4NeedsGL3Request, NeedSharedObjectSync]
+Impl. class jogamp.opengl.gl4.GL4bcImpl
+GL_VENDOR Intel Inc.
+GL_RENDERER Intel Iris OpenGL Engine
+GL_VERSION 2.1 INTEL-14.3.9
+GLSL true, has-compiler-func: true, version: 1.20 / 1.20.0
+GL FBO: basic true, full true
+GL_EXTENSIONS 128
+GLX_EXTENSIONS 0
+-----------------------------------------------------------------------------------------------------
+ShaderState: attachShaderProgram: -1 -> 1 (enable: true)
+ null
+ ShaderProgram[id=1, linked=false, inUse=false, program: 1,
+ ShaderCode[id=1, type=VERTEX_SHADER, valid=true, shader: 2, source]
+ ShaderCode[id=2, type=FRAGMENT_SHADER, valid=true, shader: 3, source]]
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.init FIN
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.reshape 0/0 800x600 of 800x600, swapInterval 1, drawable 0x7f9d55d94400, tileRendererInUse null
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.reshape FIN
+2020-02-19 21:36:05.940 Bug1398macOSContextOpsOnMainThread[1710:65756] startUpCompletionOperation main thread? ANS - YES
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.dispose: tileRendererInUse null
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.dispose FIN
diff --git a/src/test-native/bug1398/test1398-jogamp240rc-01.log b/src/test-native/bug1398/test1398-jogamp240rc-01.log
new file mode 100644
index 000000000..e2c1d310b
--- /dev/null
+++ b/src/test-native/bug1398/test1398-jogamp240rc-01.log
@@ -0,0 +1,59 @@
++ ./Bug1398macOSContextOpsOnMainThread /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/MacOS/libjli.dylib
+Bug1398macOSContextOpsOnMainThread.c:242:NSApplicationMain(): argv[1]:/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/MacOS/libjli.dylib
+Bug1398macOSContextOpsOnMainThread.c:248:NSApplicationMain(): main.1
+Bug1398macOSContextOpsOnMainThread.c:251:NSApplicationMain(): main.1.1
+2020-02-19 21:35:33.383 Bug1398macOSContextOpsOnMainThread[1697:65492] init
+Bug1398macOSContextOpsOnMainThread.c:253:NSApplicationMain(): main.1.2
+Bug1398macOSContextOpsOnMainThread.c:255:NSApplicationMain(): main.1.3
+Bug1398macOSContextOpsOnMainThread.c:258:NSApplicationMain(): main.1.5
+Bug1398macOSContextOpsOnMainThread.c:182:create_jvm_thread(): create_jvm_thread.1.1
+Bug1398macOSContextOpsOnMainThread.c:190:create_jvm_thread(): create_jvm_thread.1.2
+Bug1398macOSContextOpsOnMainThread.c:194:create_jvm_thread(): create_jvm_thread.1.X
+Bug1398macOSContextOpsOnMainThread.c:261:NSApplicationMain(): main.1.6
+Bug1398macOSContextOpsOnMainThread.c:59:launchJava(): launchJava.1.1
+Bug1398macOSContextOpsOnMainThread.c:74:launchJava(): launchJava.1.2
+Bug1398macOSContextOpsOnMainThread.c:75:launchJava(): .. using CLASSPATH .:/Users/jogamp/projects/JogAmp/gluegen/build/gluegen-rt.jar:/Users/jogamp/projects/JogAmp/jogl/build/jar/jogl-all.jar
+Bug1398macOSContextOpsOnMainThread.c:76:launchJava(): .. using LIBPATH /Users/jogamp/projects/JogAmp/gluegen/build/obj:/Users/jogamp/projects/JogAmp/jogl/build/lib
+Bug1398macOSContextOpsOnMainThread.c:30:create_vm(): Found libjli.dylib
+Bug1398macOSContextOpsOnMainThread.c:80:launchJava(): CreateVM:10ad85b80 env:700004022da8 vm_args:700004022d68
+2020-02-19 21:35:33.502 Bug1398macOSContextOpsOnMainThread[1697:65492] App starting...
+Bug1398macOSContextOpsOnMainThread.c:86:launchJava(): VM Created
+Bug1398macOSContextOpsOnMainThread.c:89:launchJava(): launchJava.1.3
+Bug1398macOSContextOpsOnMainThread.c:96:launchJava(): launchJava.1.4
+Bug1398macOSContextOpsOnMainThread.c:101:launchJava(): launchJava.1.5
+Java version: 1.8 (1.8.0_192)
+classloader:sun.misc.Launcher$AppClassLoader@764c12b6
+OS: Mac OS X 10.15.2 x86_64
+w:1920 h:1080 rr:60 bits:32 dim.w:800 dim.h:600
+gc.bounds: java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
+dim: java.awt.Dimension[width=1920,height=1080]
+Bug1398macOSContextOpsOnMainThread.c:103:launchJava(): Just passed NewObject()...
+Bug1398macOSContextOpsOnMainThread.c:122:launchJava(): launchJava.1.X
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.init: tileRendererInUse null
+RedSquareES2 init on Thread[AWT-EventQueue-0,6,main]
+Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]]
+INIT GL IS: jogamp.opengl.gl4.GL4bcImpl
+Swap Interval 0
+GL Profile GLProfile[GL2/GL2.hw]
+GL Version 2.1 (Compat profile, arb, compat[], FBO, hardware) - 2.1 INTEL-14.3.9 [GL 2.1.0, vendor 14.3.9 (INTEL-14.3.9)]
+Quirks [NoOffscreenBitmap, GL4NeedsGL3Request, NeedSharedObjectSync]
+Impl. class jogamp.opengl.gl4.GL4bcImpl
+GL_VENDOR Intel Inc.
+GL_RENDERER Intel Iris OpenGL Engine
+GL_VERSION 2.1 INTEL-14.3.9
+GLSL true, has-compiler-func: true, version: 1.20 / 1.20.0
+GL FBO: basic true, full true
+GL_EXTENSIONS 128
+GLX_EXTENSIONS 0
+-----------------------------------------------------------------------------------------------------
+ShaderState: attachShaderProgram: -1 -> 1 (enable: true)
+ null
+ ShaderProgram[id=1, linked=false, inUse=false, program: 1,
+ ShaderCode[id=1, type=VERTEX_SHADER, valid=true, shader: 2, source]
+ ShaderCode[id=2, type=FRAGMENT_SHADER, valid=true, shader: 3, source]]
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.init FIN
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.reshape 0/0 800x600 of 800x600, swapInterval 1, drawable 0x7fdd09c14d10, tileRendererInUse null
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.reshape FIN
+2020-02-19 21:35:36.508 Bug1398macOSContextOpsOnMainThread[1697:65492] startUpCompletionOperation main thread? ANS - YES
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.dispose: tileRendererInUse null
+Thread[AWT-EventQueue-0,6,main] RedSquareES2.dispose FIN