From c2b328ea96b6cb16ca39f13d4bb4d1236c4b8a1d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 14:40:44 +0100 Subject: Shader: Add '#define texture2D texture' for GLSL >= 130 ; TestGearsES2AWT add forceGL3; TextureDraw01ES2Listener uses defaultShaderCustomization() --- .../glsl/fixedfunc/shaders/FixedFuncColorTexture.fp | 1 + .../junit/jogl/demos/es2/TextureDraw01ES2Listener.java | 17 ++--------------- .../test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 14 +++++++++++++- .../junit/jogl/demos/es2/newt/TestGearsES2NEWT.java | 1 + .../junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 1 + .../es2/shader/elektronenmultiplizierer_development.fp | 1 + .../demos/es2/shader/elektronenmultiplizierer_port.fp | 1 + .../test/junit/jogl/demos/es2/shader/texture01_xxx.fp | 1 + .../test/junit/jogl/demos/es2/shader/texture02_xxx.fp | 1 + 9 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp index 82dfa24e1..130711e19 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp @@ -2,6 +2,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java index 6e701658c..4bcb073dc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -62,8 +62,6 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A this.textureData = td; } - static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; - static final String gl2_prelude = "#version 110\n"; static final String shaderBasename = "texture01_xxx"; private void initShader(GL2ES2 gl, boolean use_program) { @@ -72,19 +70,8 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A "shader", "shader/bin", shaderBasename, true); ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", shaderBasename, true); - - // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] - int rsFpPos; - if(gl.isGLES2()) { - rsVp.insertShaderSource(0, 0, es2_prelude[0]); - rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]); - } else { - rsVp.insertShaderSource(0, 0, gl2_prelude); - rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude); - } - if(gl.isGLES2()) { - rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]); - } + rsVp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); + rsFp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); // Create & Link the shader program ShaderProgram sp = new ShaderProgram(); 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 c97054d18..07899b7d6 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 @@ -61,6 +61,7 @@ import org.junit.Test; public class TestGearsES2AWT extends UITestCase { static int width, height; static boolean forceES2 = false; + static boolean forceGL3 = false; static boolean shallUseOffscreenLayer = false; static boolean shallUseOffscreenPBufferLayer = false; static boolean useMSAA = false; @@ -145,7 +146,15 @@ public class TestGearsES2AWT extends UITestCase { @Test public void test01() throws InterruptedException, InvocationTargetException { - GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2()); + final GLProfile glp; + if(forceGL3) { + glp = GLProfile.get(GLProfile.GL3); + } else if(forceES2) { + glp = GLProfile.get(GLProfile.GLES2); + } else { + glp = GLProfile.getGL2ES2(); + } + final GLCapabilities caps = new GLCapabilities(glp); if(useMSAA) { caps.setNumSamples(4); caps.setSampleBuffers(true); @@ -172,6 +181,8 @@ public class TestGearsES2AWT extends UITestCase { } catch (Exception ex) { ex.printStackTrace(); } } else if(args[i].equals("-es2")) { forceES2 = true; + } else if(args[i].equals("-gl3")) { + forceGL3 = true; } else if(args[i].equals("-vsync")) { i++; swapInterval = MiscUtils.atoi(args[i], swapInterval); @@ -197,6 +208,7 @@ public class TestGearsES2AWT extends UITestCase { } } System.err.println("forceES2 "+forceES2); + System.err.println("forceGL3 "+forceGL3); System.err.println("swapInterval "+swapInterval); System.err.println("shallUseOffscreenLayer "+shallUseOffscreenLayer); 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 90f2ab988..86831a6fa 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 @@ -372,6 +372,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); + System.err.println("forceGL3 "+forceGL3); if(waitForKey) { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); 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 21c09f78c..dbba4fae5 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 @@ -183,6 +183,7 @@ public class TestRedSquareES2NEWT extends UITestCase { System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); + System.err.println("forceGL3 "+forceGL3); org.junit.runner.JUnitCore.main(TestRedSquareES2NEWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp index 2414af5dc..60f054b46 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp @@ -12,6 +12,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp index ce0b8f5aa..77c34f74f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp @@ -15,6 +15,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp index 4cf1d9d10..c213f3ab4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp @@ -3,6 +3,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp index e15d7a154..10073e85c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp @@ -3,6 +3,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif -- cgit v1.2.3