aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-01 18:28:18 +0200
committerSven Gothel <[email protected]>2014-07-01 18:28:18 +0200
commita0498e240b9dfde345a704ec6de1d6abcee7b318 (patch)
tree7ffb59e35f2447db4126427dc552bea2a3ec7a3a /src/test/com/jogamp/opengl
parentbd76d3fe74c518b509f86c38f8871bec7f5213a2 (diff)
Fix (c) header: Due to copy & paste, wrong header was used for certain files .. (sorry)
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java55
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java203
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java127
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java147
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java189
5 files changed, 378 insertions, 343 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java
index cb76f1057..b59cddc71 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java
@@ -1,22 +1,29 @@
/**
- * Copyright (C) 2013 JogAmp Community. All rights reserved.
+ * Copyright 2013 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.
+ * 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;
@@ -25,16 +32,16 @@ import javax.media.opengl.GLEventListener;
public class GLFinishOnDisplay implements GLEventListener {
@Override
- public void init(GLAutoDrawable drawable) { }
-
+ public void init(final GLAutoDrawable drawable) { }
+
@Override
- public void dispose(GLAutoDrawable drawable) { }
-
+ public void dispose(final GLAutoDrawable drawable) { }
+
@Override
- public void display(GLAutoDrawable drawable) {
+ public void display(final GLAutoDrawable drawable) {
drawable.getGL().glFinish();
}
-
+
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
}
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
index 1de15f594..1a30d1868 100644
--- 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
@@ -1,22 +1,29 @@
/**
- * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ * Copyright 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.
+ * 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;
@@ -44,123 +51,123 @@ public class FBOMix2DemosES2 implements GLEventListener {
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 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) {
+
+ public FBOMix2DemosES2(final int swapInterval) {
demo0 = new GearsES2(-1);
demo0.setIgnoreFocus(true);
demo1 = new RedSquareES2(-1);
this.swapInterval = swapInterval;
-
+
st = new ShaderState();
- // st.setVerbose(true);
+ // st.setVerbose(true);
pmvMatrix = new PMVMatrix();
-
- fbo0 = new FBObject();
+
+ fbo0 = new FBObject();
fbo1 = new FBObject();
-
+
numSamples = 0;
demo0Only = false;
}
-
- public void setDemo0Only(boolean v) {
- this.demo0Only = v;
+
+ public void setDemo0Only(final boolean v) {
+ this.demo0Only = v;
}
public boolean getDemo0Only() { return demo0Only; }
-
- public void setMSAA(int numSamples) {
- this.numSamples=numSamples;
+
+ public void setMSAA(final int numSamples) {
+ this.numSamples=numSamples;
}
public int getMSAA() { return numSamples; }
-
- public void setDoRotation(boolean rotate) { demo1.setDoRotation(rotate); }
-
+
+ public void setDoRotation(final boolean rotate) { demo1.setDoRotation(rotate); }
+
@Override
- public void init(GLAutoDrawable drawable) {
+ public void init(final 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);
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);
+ sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
-
+
pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
- st.ownUniform(pmvMatrixUniform);
+ 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_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();
-
+ final 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_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.ownUniform(texUnit0);
st.uniform(gl, texUnit0);
texUnit1 = new GLUniformData("mgl_Texture1", 1);
- st.ownUniform(texUnit1);
+ st.ownUniform(texUnit1);
st.uniform(gl, texUnit1);
-
+
st.useProgram(gl, false);
-
+
System.err.println("**** Init");
initFBOs(gl, drawable);
-
- gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
}
-
- private void initFBOs(GL gl, GLAutoDrawable drawable) {
+
+ private void initFBOs(final GL gl, final 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.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, false);
fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, false);
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);
fbo0.resetSamplingSink(gl);
@@ -171,7 +178,7 @@ public class FBOMix2DemosES2 implements GLEventListener {
} else {
fbo0Tex = fbo0.attachTexture2D(gl, 0, true);
fbo1Tex = fbo1.attachTexture2D(gl, 0, true);
- }
+ }
numSamples=fbo0.getNumSamples();
fbo0.attachRenderbuffer(gl, Type.DEPTH, 24);
fbo0.unbind(gl);
@@ -179,12 +186,12 @@ public class FBOMix2DemosES2 implements GLEventListener {
fbo1.unbind(gl);
}
- private void resetFBOs(GL gl, GLAutoDrawable drawable) {
+ private void resetFBOs(final GL gl, final GLAutoDrawable drawable) {
fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, true);
fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, true);
if(fbo0.getNumSamples() != fbo1.getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1);
- }
+ }
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
fbo0Tex = fbo0.getSamplingSink();
@@ -192,18 +199,18 @@ public class FBOMix2DemosES2 implements GLEventListener {
} else {
fbo0Tex = (TextureAttachment) fbo0.getColorbuffer(0);
fbo1Tex = (TextureAttachment) fbo1.getColorbuffer(0);
- }
+ }
}
-
+
@Override
- public void dispose(GLAutoDrawable drawable) {
+ public void dispose(final 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;
@@ -212,32 +219,32 @@ public class FBOMix2DemosES2 implements GLEventListener {
}
@Override
- public void display(GLAutoDrawable drawable) {
+ public void display(final 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) {
@@ -245,68 +252,68 @@ public class FBOMix2DemosES2 implements GLEventListener {
fbo1.use(gl, fbo1Tex);
}
interleavedVBO.enableBuffer(gl, true);
-
+
if( !gl.isGLcore() ) {
gl.glEnable(GL.GL_TEXTURE_2D);
}
-
+
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
-
+
interleavedVBO.enableBuffer(gl, false);
fbo0.unuse(gl);
if(!demo0Only) {
fbo1.unuse(gl);
}
-
- st.useProgram(gl, false);
+
+ st.useProgram(gl, false);
}
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- if(-1 != swapInterval) {
+
+ if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
-
+
System.err.println("**** Reshape: "+width+"x"+height);
- resetFBOs(gl, drawable);
-
+ 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 = {
+ private static final float[] s_quadVertices = {
-1f, -1f, 0f, // LB
1f, -1f, 0f, // RB
-1f, 1f, 0f, // LT
- 1f, 1f, 0f // RT
+ 1f, 1f, 0f // RT
};
- private static final float[] s_quadColors = {
+ 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 = {
+ private static final float[] s_quadTexCoords = {
0f, 0f, // LB
1f, 0f, // RB
- 0f, 1f, // LT
+ 0f, 1f, // LT
1f, 1f // RT
};
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
index 641aed7d7..04af59628 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java
@@ -1,22 +1,29 @@
/**
- * Copyright (C) 2013 JogAmp Community. All rights reserved.
+ * Copyright 2013 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.
+ * 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;
@@ -47,15 +54,15 @@ public class LandscapeES2 implements GLEventListener {
private ShaderCode fragShader;
private ShaderProgram shaderProg;
private ShaderState shaderState;
- private float[] resolution;
+ private float[] resolution;
private GLUniformData resolutionUni;
- private GLUniformData timeUni;
- private GLArrayDataServer vertices;
-
- private int fcount = 0, lastm = 0;
- private int fint = 1;
-
- public LandscapeES2(int swapInterval) {
+ private GLUniformData timeUni;
+ private GLArrayDataServer vertices;
+
+ private int fcount = 0, lastm = 0;
+ private final int fint = 1;
+
+ public LandscapeES2(final int swapInterval) {
this.swapInterval = swapInterval;
}
@@ -63,11 +70,11 @@ public class LandscapeES2 implements GLEventListener {
this.swapInterval = 1;
}
- public void setVerbose(boolean v) { verbose = v; }
-
- public void init(GLAutoDrawable drawable) {
+ public void setVerbose(final boolean v) { verbose = v; }
+
+ public void init(final GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" LandscapeES2.init ...");
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
if(verbose) {
System.err.println("LandscapeES2 init on "+Thread.currentThread());
@@ -89,19 +96,19 @@ public class LandscapeES2 implements GLEventListener {
fragShader.defaultShaderCustomization(gl, true, true);
shaderProg = new ShaderProgram();
shaderProg.add(gl, vertShader, System.err);
- shaderProg.add(gl, fragShader, System.err);
-
+ shaderProg.add(gl, fragShader, System.err);
+
shaderState = new ShaderState();
shaderState.attachShaderProgram(gl, shaderProg, true);
-
+
resolution = new float[] { drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0};
resolutionUni = new GLUniformData("iResolution", 3, FloatBuffer.wrap(resolution));
shaderState.ownUniform(resolutionUni);
shaderState.uniform(gl, resolutionUni);
-
+
timeUni = new GLUniformData("iGlobalTime", 0.0f);
shaderState.ownUniform(timeUni);
-
+
vertices = GLArrayDataServer.createGLSL("inVertex", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
vertices.putf(-1.0f); vertices.putf(-1.0f);
vertices.putf(+1.0f); vertices.putf(-1.0f);
@@ -112,71 +119,71 @@ public class LandscapeES2 implements GLEventListener {
shaderState.useProgram(gl, false);
millisOffset = System.currentTimeMillis();
-
+
System.err.println(Thread.currentThread()+" LandscapeES2.init FIN");
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
System.err.println(Thread.currentThread()+" LandscapeES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle()));
-
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
+
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
-
+
shaderState.useProgram(gl, true);
-
+
resolution[0] = drawable.getSurfaceWidth();
resolution[1] = drawable.getSurfaceHeight();
shaderState.uniform(gl, resolutionUni);
-
+
shaderState.useProgram(gl, false);
}
- public void dispose(GLAutoDrawable drawable) {
+ public void dispose(final GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" LandscapeES2.dispose ... ");
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
shaderState.useProgram(gl, false);
shaderState.destroy(gl);
shaderState = null;
-
+
System.err.println(Thread.currentThread()+" LandscapeES2.dispose FIN");
}
- public void display(GLAutoDrawable drawable) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
+ public void display(final GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
// Shader fills complete framebuffer regardless of DEPTH, no Clear required.
// gl.glClearColor(0.5f, 0.1f, 0.1f, 1);
// gl.glClear(GL.GL_COLOR_BUFFER_BIT);
-
- shaderState.useProgram(gl, true);
-
+
+ shaderState.useProgram(gl, true);
+
timeUni.setData((System.currentTimeMillis() - millisOffset) / 1000.0f);
shaderState.uniform(gl, timeUni);
vertices.enableBuffer(gl, true);
gl.glDrawArrays(GL2ES2.GL_TRIANGLE_STRIP, 0, 4);
vertices.enableBuffer(gl, false);
-
+
shaderState.useProgram(gl, false);
-
+
// Compute current framerate and printout.
- frameCount++;
+ frameCount++;
fcount += 1;
- int m = (int) (System.currentTimeMillis() - millisOffset);
+ final int m = (int) (System.currentTimeMillis() - millisOffset);
if (m - lastm > 1000 * fint) {
frameRate = (float)(fcount) / fint;
fcount = 0;
lastm = m;
- }
+ }
if (frameCount % TARGET_FPS == 0) {
System.out.println("FrameCount: " + frameCount + " - " + "FrameRate: " + frameRate);
- }
+ }
}
-
+
boolean confinedFixedCenter = false;
-
- public void setConfinedFixedCenter(boolean v) {
+
+ public void setConfinedFixedCenter(final boolean v) {
confinedFixedCenter = v;
- }
+ }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
index b69505457..58161f50a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java
@@ -1,22 +1,29 @@
/**
- * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ * Copyright 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.
+ * 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;
@@ -37,24 +44,24 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class Mix2TexturesES2 implements GLEventListener {
private final int swapInterval;
-
+
private final ShaderState st;
private final PMVMatrix pmvMatrix;
private final GLUniformData texUnit0, texUnit1;
-
- private Object syncTexIDs = new Object();
+
+ private final Object syncTexIDs = new Object();
private int texID0, texID1;
private ShaderProgram sp0;
private GLUniformData pmvMatrixUniform;
private GLArrayDataServer interleavedVBO;
-
- public Mix2TexturesES2(int swapInterval, int texUnit0, int texUnit1) {
+
+ public Mix2TexturesES2(final int swapInterval, final int texUnit0, final int texUnit1) {
this.swapInterval = swapInterval;
-
+
st = new ShaderState();
- // st.setVerbose(true);
+ // st.setVerbose(true);
pmvMatrix = new PMVMatrix();
-
+
if(0 == texUnit1) {
this.texUnit0 = new GLUniformData("mgl_ActiveTexture", texUnit0);
this.texUnit1 = null;
@@ -65,147 +72,147 @@ public class Mix2TexturesES2 implements GLEventListener {
this.texID0 = 0;
this.texID1 = 0;
}
-
- public void setTexID0(int texID) {
+
+ public void setTexID0(final int texID) {
synchronized( syncTexIDs ) {
this.texID0 = texID;
}
}
- public void setTexID1(int texID) {
+ public void setTexID1(final int texID) {
synchronized( syncTexIDs ) {
this.texID1 = texID;
}
}
-
+
@Override
- public void init(GLAutoDrawable drawable) {
+ public void init(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
+
final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, Mix2TexturesES2.class, "shader",
"shader/bin", "texture01_xxx", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, Mix2TexturesES2.class, "shader",
"shader/bin", null == texUnit1 ? "texture01_xxx" : "texture02_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);
+ sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
-
+
pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
- st.ownUniform(pmvMatrixUniform);
+ 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_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();
-
+ final 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_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);
-
+
st.ownUniform(texUnit0);
st.uniform(gl, texUnit0);
if(null != texUnit1) {
- st.ownUniform(texUnit1);
+ st.ownUniform(texUnit1);
st.uniform(gl, texUnit1);
}
-
- st.useProgram(gl, false);
+
+ st.useProgram(gl, false);
}
-
+
@Override
- public void dispose(GLAutoDrawable drawable) {
+ public void dispose(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
st.destroy(gl);
-
+
sp0 = null;
pmvMatrixUniform = null;
interleavedVBO = null;
}
@Override
- public void display(GLAutoDrawable drawable) {
+ public void display(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
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);
-
+
interleavedVBO.enableBuffer(gl, true);
-
+
synchronized( syncTexIDs ) {
if(0<texID0) {
gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue());
gl.glBindTexture(GL.GL_TEXTURE_2D, texID0);
}
-
+
if(0<texID1 && null != texUnit1) {
gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue());
gl.glBindTexture(GL.GL_TEXTURE_2D, texID1);
}
-
+
if( !gl.isGLcore() ) {
gl.glEnable(GL.GL_TEXTURE_2D);
}
-
+
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
}
-
+
interleavedVBO.enableBuffer(gl, false);
-
- st.useProgram(gl, false);
+
+ st.useProgram(gl, false);
}
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- if(-1 != swapInterval) {
+
+ if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
-
+
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 = {
+ private static final float[] s_quadVertices = {
-1f, -1f, 0f, // LB
1f, -1f, 0f, // RB
-1f, 1f, 0f, // LT
- 1f, 1f, 0f // RT
+ 1f, 1f, 0f // RT
};
- private static final float[] s_quadColors = {
+ 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 = {
+ private static final float[] s_quadTexCoords = {
0f, 0f, // LB
1f, 0f, // RB
- 0f, 1f, // LT
+ 0f, 1f, // LT
1f, 1f // RT
};
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
index 3cc667f99..da9281207 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
@@ -1,22 +1,29 @@
/**
- * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ * Copyright 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.
+ * 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;
@@ -42,135 +49,135 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
private final GLEventListener demo;
private final int swapInterval;
private boolean clearBuffers = true;
- private int numSamples;
+ private int numSamples;
int textureUnit;
boolean keepTextureBound;
-
+
private final ShaderState st;
private final PMVMatrix pmvMatrix;
-
- private final FBObject fbo0;
-
+
+ private final FBObject fbo0;
+
private TextureAttachment fbo0Tex;
-
+
private ShaderProgram sp0;
private GLUniformData pmvMatrixUniform;
private GLArrayDataServer interleavedVBO;
private GLUniformData texUnit0;
-
- public TextureDraw02ES2ListenerFBO(GLEventListener demo, int swapInterval, int textureUnit) {
+
+ public TextureDraw02ES2ListenerFBO(final GLEventListener demo, final int swapInterval, final int textureUnit) {
this.demo = demo;
this.swapInterval = swapInterval;
this.textureUnit = textureUnit;
this.keepTextureBound = false;
-
+
st = new ShaderState();
- // st.setVerbose(true);
+ // st.setVerbose(true);
pmvMatrix = new PMVMatrix();
-
+
fbo0 = new FBObject();
-
+
numSamples = 0;
}
-
- public void setClearBuffers(boolean v) { clearBuffers = v; }
-
- public void setKeepTextureBound(boolean v) {
+
+ public void setClearBuffers(final boolean v) { clearBuffers = v; }
+
+ public void setKeepTextureBound(final boolean v) {
this.keepTextureBound = v;
}
- public void setMSAA(int numSamples) {
- this.numSamples=numSamples;
+ public void setMSAA(final int numSamples) {
+ this.numSamples=numSamples;
}
public int getMSAA() { return numSamples; }
-
+
@Override
- public void init(GLAutoDrawable drawable) {
+ public void init(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
+
demo.init(drawable);
-
+
final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextureDraw02ES2ListenerFBO.class, "shader",
"shader/bin", "texture01_xxx", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextureDraw02ES2ListenerFBO.class, "shader",
"shader/bin", "texture02_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);
+ sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0, true);
-
+
pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
- st.ownUniform(pmvMatrixUniform);
+ 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_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();
-
+ final 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_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", textureUnit);
- st.ownUniform(texUnit0);
+ st.ownUniform(texUnit0);
st.uniform(gl, texUnit0);
-
+
st.useProgram(gl, false);
-
- gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
}
-
- private void initFBOs(GL gl, int width, int height) {
+
+ private void initFBOs(final GL gl, final int width, final int height) {
// remove all texture attachments, since MSAA uses just color-render-buffer
// and non-MSAA uses texture2d-buffer
fbo0.detachAllColorbuffer(gl);
-
+
fbo0.reset(gl, width, height, numSamples, false);
numSamples = fbo0.getNumSamples();
-
+
if(numSamples>0) {
fbo0.attachColorbuffer(gl, 0, true);
fbo0.resetSamplingSink(gl);
fbo0Tex = fbo0.getSamplingSink();
} else {
fbo0Tex = fbo0.attachTexture2D(gl, 0, true);
- }
+ }
numSamples=fbo0.getNumSamples();
fbo0.attachRenderbuffer(gl, Type.DEPTH, 24);
fbo0.unbind(gl);
}
- private void resetFBOs(GL gl, int width, int height) {
+ private void resetFBOs(final GL gl, final int width, final int height) {
fbo0.reset(gl, width, height, numSamples, true);
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
fbo0Tex = fbo0.getSamplingSink();
} else {
fbo0Tex = (TextureAttachment) fbo0.getColorbuffer(0);
- }
+ }
}
-
+
@Override
- public void dispose(GLAutoDrawable drawable) {
+ public void dispose(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
demo.dispose(drawable);
fbo0.destroy(gl);
st.destroy(gl);
-
+
fbo0Tex = null;
sp0 = null;
pmvMatrixUniform = null;
@@ -178,28 +185,28 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
}
@Override
- public void display(GLAutoDrawable drawable) {
+ public void display(final GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
if( fbo0.getNumSamples() != numSamples ) {
System.err.println("**** NumSamples: "+fbo0.getNumSamples()+" -> "+numSamples);
resetFBOs(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
}
-
+
if(0 < numSamples) {
gl.glEnable(GL.GL_MULTISAMPLE);
}
-
+
fbo0.bind(gl);
demo.display(drawable);
fbo0.unbind(gl);
-
+
st.useProgram(gl, true);
if( clearBuffers ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
-
+
if( !keepTextureBound ) {
gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue());
fbo0.use(gl, fbo0Tex);
@@ -209,41 +216,41 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
}
gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue());
interleavedVBO.enableBuffer(gl, true);
-
+
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
-
+
interleavedVBO.enableBuffer(gl, false);
-
+
if( !keepTextureBound ) {
fbo0.unuse(gl);
}
-
- st.useProgram(gl, false);
+
+ st.useProgram(gl, false);
}
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- if(-1 != swapInterval) {
+
+ if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
-
+
if( !fbo0.isInitialized() ) {
System.err.println("**** Reshape.Init: "+width+"x"+height);
initFBOs(gl, width, height);
- } else {
+ } else {
System.err.println("**** Reshape.Reset: "+width+"x"+height);
if( keepTextureBound ) {
fbo0.unuse(gl);
}
resetFBOs(gl, width, height);
}
-
+
fbo0.bind(gl);
demo.reshape(drawable, x, y, width, height);
fbo0.unbind(gl);
-
+
if( keepTextureBound ) {
gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue());
fbo0.use(gl, fbo0Tex);
@@ -251,35 +258,35 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
gl.glEnable(GL.GL_TEXTURE_2D);
}
}
-
+
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 = {
+ private static final float[] s_quadVertices = {
-1f, -1f, 0f, // LB
1f, -1f, 0f, // RB
-1f, 1f, 0f, // LT
- 1f, 1f, 0f // RT
+ 1f, 1f, 0f // RT
};
- private static final float[] s_quadColors = {
+ 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 = {
+ private static final float[] s_quadTexCoords = {
0f, 0f, // LB
1f, 0f, // RB
- 0f, 1f, // LT
+ 0f, 1f, // LT
1f, 1f // RT
};
}