summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-11 02:36:43 +0200
committerSven Gothel <[email protected]>2014-06-11 02:36:43 +0200
commitea0f37d33acff83091fdb0e47a70cfad7186dfe8 (patch)
treeaf032d4c02b3df432b31578b2da5f6abae6814f5
parent3b6e6caeb24a112a2b1fbee5f54bbdc0bbf865c0 (diff)
Graph RegionRenderer: Fix GL3 and ES3 GLSL issues
Macro redefine 'texture2D -> texture' was added _after_ the custom texture lookup insertion causing GL3-core to fail.
-rw-r--r--make/scripts/tests.sh14
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java49
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java46
5 files changed, 111 insertions, 33 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index bd19633f0..e081f3156 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -266,19 +266,13 @@ function jrun() {
#X_ARGS="-Xrs"
#X_ARGS="-Dsun.awt.disableMixing=true"
#D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer"
- #D_ARGS="-Djogl.debug.AudioSink -Djoal.openal.lib=soft"
- #D_ARGS="-Djogl.debug.AudioSink -Djogl.debug.GLMediaPlayer"
- #D_ARGS="-Djogl.debug.AudioSink -Djogl.debug.GLMediaPlayer.Native"
- #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native"
- #D_ARGS="-Djogl.debug.GLMediaPlayer.Native"
#D_ARGS="-Djogl.debug.AudioSink -Djoal.openal.lib=system"
- #D_ARGS="-Djogl.debug.AudioSink"
- #D_ARGS="-Djogl.debug.AudioSink.trace"
+ #D_ARGS="-Djogl.debug.AudioSink -Djogl.debug.AudioSink.trace"
+ #D_ARGS="-Djogl.debug.AudioSink -Djogl.debug.GLMediaPlayer"
#D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native"
#D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLSLCode"
#D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer"
#D_ARGS="-Djogl.debug.GLMediaPlayer.Native"
- D_ARGS="-Djogl.debug.GLSLCode"
if [ $awton -eq 1 ] ; then
export USE_CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH
@@ -373,9 +367,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $*
#testawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtCanvasAWTDemo $*
-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.graph.demos.GPUUISceneNewtDemo $*
+testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.ManualHiDPIBufferedImage01AWT $*
#
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 e8dc5f090..754eb56e8 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -284,11 +284,11 @@ public class RegionRenderer {
private static final String SHADER_SRC_SUB = "";
private static final String SHADER_BIN_SUB = "bin";
- private static String USE_COLOR_CHANNEL = "#define USE_COLOR_CHANNEL 1\n";
- private static String USE_COLOR_TEXTURE = "#define USE_COLOR_TEXTURE 1\n";
- private static String DEF_SAMPLE_COUNT = "#define SAMPLE_COUNT ";
- private static String CONST_SAMPLE_COUNT = "const float sample_count = ";
- private static String MAIN_BEGIN = "void main (void)\n{\n";
+ private static String GLSL_USE_COLOR_CHANNEL = "#define USE_COLOR_CHANNEL 1\n";
+ private static String GLSL_USE_COLOR_TEXTURE = "#define USE_COLOR_TEXTURE 1\n";
+ private static String GLSL_DEF_SAMPLE_COUNT = "#define SAMPLE_COUNT ";
+ private static String GLSL_CONST_SAMPLE_COUNT = "const float sample_count = ";
+ private static String GLSL_MAIN_BEGIN = "void main (void)\n{\n";
private static final String gcuTexture2D = "gcuTexture2D";
private String getVersionedShaderName() {
@@ -434,9 +434,6 @@ public class RegionRenderer {
final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, AttributeNames.class, SHADER_SRC_SUB, SHADER_BIN_SUB, vertexShaderName, true);
final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, AttributeNames.class, SHADER_SRC_SUB, SHADER_BIN_SUB, versionedBaseName+"-segment-head", true);
- int posVp = 0;
- int posFp = 0;
-
if( isPass1ColorTexSeq && GLES2.GL_TEXTURE_EXTERNAL_OES == colorTexSeq.getTextureTarget() ) {
if( !gl.isExtensionAvailable(GLExtensions.OES_EGL_image_external) ) {
throw new GLException(GLExtensions.OES_EGL_image_external+" requested but not available");
@@ -451,9 +448,12 @@ public class RegionRenderer {
supressGLSLVersionES30 = true;
}
}
- posVp = rsVp.defaultShaderCustomization(gl, !supressGLSLVersionES30, true);
+ //
+ // GLSL customization at top
+ //
+ int posVp = rsVp.defaultShaderCustomization(gl, !supressGLSLVersionES30, true);
// rsFp.defaultShaderCustomization(gl, true, true);
- posFp = supressGLSLVersionES30 ? 0 : rsFp.addGLSLVersion(gl);
+ int posFp = supressGLSLVersionES30 ? 0 : rsFp.addGLSLVersion(gl);
if( isPass1ColorTexSeq ) {
posFp = rsFp.insertShaderSource(0, posFp, colorTexSeq.getRequiredExtensionsShaderStub());
}
@@ -468,17 +468,32 @@ public class RegionRenderer {
} else {
posFp = rsFp.addDefaultShaderPrecision(gl, posFp);
}
+
+ //
+ // GLSL append from here on
+ posFp = -1;
+
if( Region.hasColorChannel( renderModes ) ) {
- posVp = rsVp.insertShaderSource(0, posVp, USE_COLOR_CHANNEL);
- posFp = rsFp.insertShaderSource(0, posFp, USE_COLOR_CHANNEL);
+ posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_CHANNEL);
+ posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_CHANNEL);
}
if( Region.hasColorTexture( renderModes ) ) {
- posVp = rsVp.insertShaderSource(0, posVp, USE_COLOR_TEXTURE);
- posFp = rsFp.insertShaderSource(0, posFp, USE_COLOR_TEXTURE);
+ posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_TEXTURE);
+ posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_TEXTURE);
}
if( !pass1 ) {
- posFp = rsFp.insertShaderSource(0, posFp, DEF_SAMPLE_COUNT+sel1.sampleCount+"\n");
- posFp = rsFp.insertShaderSource(0, posFp, CONST_SAMPLE_COUNT+sel1.sampleCount+".0;\n");
+ posFp = rsFp.insertShaderSource(0, posFp, GLSL_DEF_SAMPLE_COUNT+sel1.sampleCount+"\n");
+ posFp = rsFp.insertShaderSource(0, posFp, GLSL_CONST_SAMPLE_COUNT+sel1.sampleCount+".0;\n");
+ }
+
+ try {
+ posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "uniforms.glsl");
+ posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "varyings.glsl");
+ } catch (IOException ioe) {
+ throw new RuntimeException("Failed to read: includes", ioe);
+ }
+ if( 0 > posFp ) {
+ throw new RuntimeException("Failed to read: includes");
}
final String texLookupFuncName;
@@ -490,7 +505,7 @@ public class RegionRenderer {
texLookupFuncName = null;
}
- posFp = rsFp.insertShaderSource(0, -1, MAIN_BEGIN);
+ posFp = rsFp.insertShaderSource(0, posFp, GLSL_MAIN_BEGIN);
final String passS = pass1 ? "-pass1-" : "-pass2-";
final String shaderSegment = versionedBaseName+passS+sel1.tech+sel1.sub+".glsl";
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp
index 26e2bcf24..05407a4e6 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-segment-head.fp
@@ -12,8 +12,5 @@
#define mgl_FragColor gl_FragColor
#endif
-#include uniforms.glsl
-#include varyings.glsl
-
#define GetSample(texUnit, texCoord, psize, cx, cy, offX, offY) texture2D(texUnit, texCoord + psize * vec2(cx+offX, cy+offY))
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java
index 011b20c35..bd0af580a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java
@@ -50,6 +50,12 @@ public class GPUUISceneNewtCanvasAWTDemo {
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
int width = 800, height = 400;
int x = 10, y = 10;
+
+ boolean forceES2 = false;
+ boolean forceES3 = false;
+ boolean forceGL3 = false;
+ boolean forceGLDef = false;
+
if( 0 != args.length ) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-smsaa")) {
@@ -88,9 +94,21 @@ public class GPUUISceneNewtCanvasAWTDemo {
final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]);
reqSurfacePixelScale[0] = pS;
reqSurfacePixelScale[1] = pS;
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-es3")) {
+ forceES3 = true;
+ } else if(args[i].equals("-gl3")) {
+ forceGL3 = true;
+ } else if(args[i].equals("-gldef")) {
+ forceGLDef = true;
}
}
}
+ System.err.println("forceES2 "+forceES2);
+ System.err.println("forceES3 "+forceES3);
+ System.err.println("forceGL3 "+forceGL3);
+ System.err.println("forceGLDef "+forceGLDef);
System.err.println("Desired win size "+width+"x"+height);
System.err.println("Desired win pos "+x+"/"+y);
System.err.println("Scene MSAA Samples "+SceneMSAASamples);
@@ -98,7 +116,19 @@ public class GPUUISceneNewtCanvasAWTDemo {
System.err.println("Graph VBAA Mode "+GraphVBAAMode);
System.err.println("Graph Auto Mode "+GraphAutoMode+" no-AA dpi threshold");
- GLProfile glp = GLProfile.getGL2ES2();
+ final GLProfile glp;
+ if(forceGLDef) {
+ glp = GLProfile.getDefault();
+ } else if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES3) {
+ glp = GLProfile.get(GLProfile.GLES3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getGL2ES2();
+ }
+ System.err.println("GLProfile: "+glp);
GLCapabilities caps = new GLCapabilities(glp);
caps.setAlphaBits(4);
if( SceneMSAASamples > 0 ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
index dbf0838eb..ee3b129b7 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
@@ -1,5 +1,6 @@
package com.jogamp.opengl.test.junit.graph.demos;
+import javax.media.nativewindow.ScalableSurface;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -19,9 +20,17 @@ public class GPUUISceneNewtDemo {
static boolean GraphMSAAMode = false;
static float GraphAutoMode = GPUUISceneGLListener0A.DefaultNoAADPIThreshold;
+ static int[] reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
+
public static void main(String[] args) {
int width = 800, height = 400;
int x = 10, y = 10;
+
+ boolean forceES2 = false;
+ boolean forceES3 = false;
+ boolean forceGL3 = false;
+ boolean forceGLDef = false;
+
if( 0 != args.length ) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-smsaa")) {
@@ -55,9 +64,26 @@ public class GPUUISceneNewtDemo {
} else if(args[i].equals("-y")) {
i++;
y = MiscUtils.atoi(args[i], y);
+ } else if(args[i].equals("-pixelScale")) {
+ i++;
+ final int pS = MiscUtils.atoi(args[i], reqSurfacePixelScale[0]);
+ reqSurfacePixelScale[0] = pS;
+ reqSurfacePixelScale[1] = pS;
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-es3")) {
+ forceES3 = true;
+ } else if(args[i].equals("-gl3")) {
+ forceGL3 = true;
+ } else if(args[i].equals("-gldef")) {
+ forceGLDef = true;
}
}
}
+ System.err.println("forceES2 "+forceES2);
+ System.err.println("forceES3 "+forceES3);
+ System.err.println("forceGL3 "+forceGL3);
+ System.err.println("forceGLDef "+forceGLDef);
System.err.println("Desired win size "+width+"x"+height);
System.err.println("Desired win pos "+x+"/"+y);
System.err.println("Scene MSAA Samples "+SceneMSAASamples);
@@ -65,7 +91,19 @@ public class GPUUISceneNewtDemo {
System.err.println("Graph VBAA Mode "+GraphVBAAMode);
System.err.println("Graph Auto Mode "+GraphAutoMode+" no-AA dpi threshold");
- GLProfile glp = GLProfile.getGL2ES2();
+ final GLProfile glp;
+ if(forceGLDef) {
+ glp = GLProfile.getDefault();
+ } else if(forceGL3) {
+ glp = GLProfile.get(GLProfile.GL3);
+ } else if(forceES3) {
+ glp = GLProfile.get(GLProfile.GLES3);
+ } else if(forceES2) {
+ glp = GLProfile.get(GLProfile.GLES2);
+ } else {
+ glp = GLProfile.getGL2ES2();
+ }
+ System.err.println("GLProfile: "+glp);
GLCapabilities caps = new GLCapabilities(glp);
caps.setAlphaBits(4);
if( SceneMSAASamples > 0 ) {
@@ -89,6 +127,8 @@ public class GPUUISceneNewtDemo {
window.setPosition(x, y);
window.setSize(width, height);
window.setTitle("GraphUI Newt Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples);
+ window.setSurfaceScale(reqSurfacePixelScale);
+ final int[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new int[2]);
GPUUISceneGLListener0A sceneGLListener = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(GraphAutoMode, DEBUG, TRACE) :
new GPUUISceneGLListener0A(rmode, DEBUG, TRACE);
@@ -107,6 +147,10 @@ public class GPUUISceneNewtDemo {
});
window.setVisible(true);
+ final int[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new int[2]);
+ System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
+ valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
+ hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
animator.start();
}
}