diff options
Diffstat (limited to 'src/test/com/jogamp/opengl')
32 files changed, 1182 insertions, 583 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java index a328a2bac..a369f542f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java @@ -36,7 +36,6 @@ import java.io.IOException; import java.nio.ByteBuffer; import javax.media.opengl.GL; -import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; @@ -58,15 +57,13 @@ public class TestGPUMemSec01NEWT extends UITestCase { static NEWTGLContext.WindowContext createCurrentGLOffscreenWindow(int width, int height) throws GLException, InterruptedException { final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getGL2ES2(), width, height, true); - final GL _gl = winctx.context.getGL(); - Assert.assertTrue(_gl.isGL2GL3()); - final GL2GL3 gl = _gl.getGL2GL3(); + final GL gl = winctx.context.getGL(); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); // misc GL setup gl.glClearColor(1, 1, 1, 1); - gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glEnable(GL.GL_DEPTH_TEST); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); gl.glViewport(0, 0, width, height); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); @@ -232,36 +229,38 @@ public class TestGPUMemSec01NEWT extends UITestCase { } @Test - public void testReadPixels_640x480xREDxUB() throws InterruptedException { + public void testReadPixels_640x480xRGBxUB() throws InterruptedException { final int width = 640; final int height= 480; - + // preset .. final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height); final GLDrawable drawable = winctx.context.getGLDrawable(); - final GL2GL3 gl = winctx.context.getGL().getGL2GL3(); + final GL gl = winctx.context.getGL(); // 2 x too small - 0 x alignment - Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, width, height)); + Assert.assertEquals(2, readPixelsCheck(gl, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, width, height)); drawable.swapBuffers(); Thread.sleep(50); NEWTGLContext.destroyWindow(winctx); } - + @Test - public void testReadPixels_640x480xRGBxUB() throws InterruptedException { - final int width = 640; - final int height= 480; + public void testReadPixels_102x100xRGBxUB() throws InterruptedException { + final int wwidth = 640; + final int wheight= 480; + final int rwidth = 102; + final int rheight= 100; // preset .. - final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height); + final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight); final GLDrawable drawable = winctx.context.getGLDrawable(); - final GL2GL3 gl = winctx.context.getGL().getGL2GL3(); + final GL gl = winctx.context.getGL(); - // 2 x too small - 0 x alignment - Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, width, height)); + // 2 x too small - 2 x alignment + Assert.assertEquals(4, readPixelsCheck(gl, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, rwidth, rheight)); drawable.swapBuffers(); Thread.sleep(50); @@ -270,40 +269,46 @@ public class TestGPUMemSec01NEWT extends UITestCase { } @Test - public void testReadPixels_102x100xREDxUB() throws InterruptedException { - int wwidth = 640; - int wheight= 480; - int rwidth = 102; - int rheight= 100; + public void testReadPixelsGL2GL3_640x480xREDxUB() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2GL3)) { + System.err.println("GL2GL3 n/a skip test"); + return; + } + final int width = 640; + final int height= 480; // preset .. - final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight); + final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height); final GLDrawable drawable = winctx.context.getGLDrawable(); final GL2GL3 gl = winctx.context.getGL().getGL2GL3(); - // 2 x too small - 2 x alignment - Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, rwidth, rheight)); + // 2 x too small - 0 x alignment + Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, width, height)); drawable.swapBuffers(); Thread.sleep(50); NEWTGLContext.destroyWindow(winctx); } - + @Test - public void testReadPixels_102x100xRGBxUB() throws InterruptedException { - final int wwidth = 640; - final int wheight= 480; - final int rwidth = 102; - final int rheight= 100; - + public void testReadPixelsGL2GL3_102x100xREDxUB() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2GL3)) { + System.err.println("GL2GL3 n/a skip test"); + return; + } + int wwidth = 640; + int wheight= 480; + int rwidth = 102; + int rheight= 100; + // preset .. final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight); final GLDrawable drawable = winctx.context.getGLDrawable(); final GL2GL3 gl = winctx.context.getGL().getGL2GL3(); // 2 x too small - 2 x alignment - Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, rwidth, rheight)); + Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, rwidth, rheight)); drawable.swapBuffers(); Thread.sleep(50); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java new file mode 100644 index 000000000..bad04addc --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java @@ -0,0 +1,111 @@ +/** + * Copyright 2011 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.test.junit.jogl.acore; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.test.junit.util.NEWTGLContext; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +/** + * + * @author Luz, et.al. + */ +public class TestMapBuffer01NEWT extends UITestCase { + static final boolean DEBUG = false; + + @Test + public void testWriteRead01a() throws InterruptedException { + ByteBuffer verticiesBB = ByteBuffer.allocate(4*9); + verticiesBB.order(ByteOrder.nativeOrder()); + testWriteRead01(verticiesBB); + } + @Test + public void testWriteRead01b() throws InterruptedException { + ByteBuffer verticiesBB = Buffers.newDirectByteBuffer(4*9); + testWriteRead01(verticiesBB); + } + + private void testWriteRead01(ByteBuffer verticiesBB) throws InterruptedException { + final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getDefault(), 800, 600, true); + final GL gl = winctx.context.getGL(); + + int[] vertexBuffer = new int[1]; + + verticiesBB.putFloat(0); + verticiesBB.putFloat(0.5f); + verticiesBB.putFloat(0); + + verticiesBB.putFloat(0.5f); + verticiesBB.putFloat(-0.5f); + verticiesBB.putFloat(0); + + verticiesBB.putFloat(-0.5f); + verticiesBB.putFloat(-0.5f); + verticiesBB.putFloat(0); + verticiesBB.rewind(); + if(DEBUG) { + for(int i=0; i < verticiesBB.capacity(); i+=4) { + System.out.println("java "+i+": "+verticiesBB.getFloat(i)); + } + } + + gl.glGenBuffers(1, vertexBuffer, 0); + + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer[0]); + + // gl.glBufferData(GL3.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL3.GL_STATIC_READ); + gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_DRAW); + + ByteBuffer bb = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2GL3.GL_READ_ONLY); + // gl.glUnmapBuffer(GL3.GL_ARRAY_BUFFER); + if(DEBUG) { + for(int i=0; i < bb.capacity(); i+=4) { + System.out.println("gpu "+i+": "+bb.getFloat(i)); + } + } + for(int i=0; i < bb.capacity(); i+=4) { + Assert.assertEquals(verticiesBB.getFloat(i), bb.getFloat(i), 0.0); + } + NEWTGLContext.destroyWindow(winctx); + } + public static void main(String args[]) throws IOException { + String tstname = TestMapBuffer01NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java new file mode 100644 index 000000000..19c207f80 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java @@ -0,0 +1,232 @@ +/** + * Copyright (C) 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. + */ +package com.jogamp.opengl.test.junit.jogl.demos; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.util.GLArrayDataServer; + +/** + * GearsObject.java <BR> + * author: Brian Paul (converted to Java by Sven Gothel) <P> + */ +public abstract class GearsObject { + public static final FloatBuffer red = Buffers.newDirectFloatBuffer( new float[] { 0.8f, 0.1f, 0.0f, 0.7f } ); + public static final FloatBuffer green = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 0.8f, 0.2f, 0.7f } ); + public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.2f, 0.2f, 1.0f, 0.7f } ); + public static final float M_PI = (float)Math.PI; + + public final GLArrayDataServer frontFace; + public final GLArrayDataServer frontSide; + public final GLArrayDataServer backFace; + public final GLArrayDataServer backSide; + public final GLArrayDataServer outwardFace; + public final GLArrayDataServer insideRadiusCyl; + + public abstract void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components); + public abstract void draw(GL gl, float x, float y, float angle, FloatBuffer color); + + public GearsObject ( + float inner_radius, + float outer_radius, + float width, + int teeth, + float tooth_depth) + { + final float dz = width * 0.5f; + int i; + float r0, r1, r2; + float angle, da; + float u, v, len; + float s[] = new float[5]; + float c[] = new float[5]; + float normal[] = new float[3]; + // final int tris_per_tooth = 32; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0f; + r2 = outer_radius + tooth_depth / 2.0f; + + da = 2.0f * (float) Math.PI / teeth / 4.0f; + + s[4] = 0; // sin(0f) + c[4] = 1; // cos(0f) + + System.err.println("teeth: "+teeth); + + frontFace = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 4*teeth+2, GL.GL_STATIC_DRAW); + addInterleavedVertexAndNormalArrays(frontFace, 3); + backFace = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 4*teeth+2, GL.GL_STATIC_DRAW); + addInterleavedVertexAndNormalArrays(backFace, 3); + frontSide = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 6*teeth, GL.GL_STATIC_DRAW); + addInterleavedVertexAndNormalArrays(frontSide, 3); + backSide = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 6*teeth, GL.GL_STATIC_DRAW); + addInterleavedVertexAndNormalArrays(backSide, 3); + outwardFace = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 4*4*teeth+2, GL.GL_STATIC_DRAW); + addInterleavedVertexAndNormalArrays(outwardFace, 3); + insideRadiusCyl = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 2*teeth+2, GL.GL_STATIC_DRAW); + addInterleavedVertexAndNormalArrays(insideRadiusCyl, 3); + + for (i = 0; i < teeth; i++) { + angle = i * 2.0f * M_PI / teeth; + sincos(angle + da * 0f, s, 0, c, 0); + sincos(angle + da * 1f, s, 1, c, 1); + sincos(angle + da * 2f, s, 2, c, 2); + sincos(angle + da * 3f, s, 3, c, 3); + + /* front */ + normal[0] = 0.0f; + normal[1] = 0.0f; + normal[2] = 1.0f; + + /* front face - GL.GL_TRIANGLE_STRIP */ + vert(frontFace, r0 * c[0], r0 * s[0], dz, normal); + vert(frontFace, r1 * c[0], r1 * s[0], dz, normal); + vert(frontFace, r0 * c[0], r0 * s[0], dz, normal); + vert(frontFace, r1 * c[3], r1 * s[3], dz, normal); + + /* front sides of teeth - GL.GL_TRIANGLES */ + vert(frontSide, r1 * c[0], r1 * s[0], dz, normal); + vert(frontSide, r2 * c[1], r2 * s[1], dz, normal); + vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); + vert(frontSide, r1 * c[0], r1 * s[0], dz, normal); + vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); + vert(frontSide, r1 * c[3], r1 * s[3], dz, normal); + + /* back */ + normal[0] = 0.0f; + normal[1] = 0.0f; + normal[2] = -1.0f; + + /* back face - GL.GL_TRIANGLE_STRIP */ + vert(backFace, r1 * c[0], r1 * s[0], -dz, normal); + vert(backFace, r0 * c[0], r0 * s[0], -dz, normal); + vert(backFace, r1 * c[3], r1 * s[3], -dz, normal); + vert(backFace, r0 * c[0], r0 * s[0], -dz, normal); + + /* back sides of teeth - GL.GL_TRIANGLES*/ + vert(backSide, r1 * c[3], r1 * s[3], -dz, normal); + vert(backSide, r2 * c[2], r2 * s[2], -dz, normal); + vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); + vert(backSide, r1 * c[3], r1 * s[3], -dz, normal); + vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); + vert(backSide, r1 * c[0], r1 * s[0], -dz, normal); + + /* outward faces of teeth */ + u = r2 * c[1] - r1 * c[0]; + v = r2 * s[1] - r1 * s[0]; + len = (float)Math.sqrt(u * u + v * v); + u /= len; + v /= len; + normal[0] = v; + normal[1] = -u; + normal[2] = 0.0f; + + vert(outwardFace, r1 * c[0], r1 * s[0], dz, normal); + vert(outwardFace, r1 * c[0], r1 * s[0], -dz, normal); + vert(outwardFace, r2 * c[1], r2 * s[1], dz, normal); + vert(outwardFace, r2 * c[1], r2 * s[1], -dz, normal); + + normal[0] = c[0]; + normal[1] = s[0]; + vert(outwardFace, r2 * c[1], r2 * s[1], dz, normal); + vert(outwardFace, r2 * c[1], r2 * s[1], -dz, normal); + vert(outwardFace, r2 * c[2], r2 * s[2], dz, normal); + vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal); + + normal[0] = ( r1 * s[3] - r2 * s[2] ); + normal[1] = ( r1 * c[3] - r2 * c[2] ) * -1.0f ; + vert(outwardFace, r2 * c[2], r2 * s[2], dz, normal); + vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal); + vert(outwardFace, r1 * c[3], r1 * s[3], dz, normal); + vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal); + + normal[0] = c[0]; + normal[1] = s[0]; + vert(outwardFace, r1 * c[3], r1 * s[3], dz, normal); + vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal); + vert(outwardFace, r1 * c[0], r1 * s[0], dz, normal); + vert(outwardFace, r1 * c[0], r1 * s[0], -dz, normal); + + /* inside radius cylinder */ + normal[0] = c[0] * -1.0f; + normal[1] = s[0] * -1.0f; + normal[2] = 0.0f; + vert(insideRadiusCyl, r0 * c[0], r0 * s[0], -dz, normal); + vert(insideRadiusCyl, r0 * c[0], r0 * s[0], dz, normal); + } + /* finish front face */ + normal[0] = 0.0f; + normal[1] = 0.0f; + normal[2] = 1.0f; + vert(frontFace, r0 * c[4], r0 * s[4], dz, normal); + vert(frontFace, r1 * c[4], r1 * s[4], dz, normal); + frontFace.seal(true); + + /* finish back face */ + normal[2] = -1.0f; + vert(backFace, r1 * c[4], r1 * s[4], -dz, normal); + vert(backFace, r0 * c[4], r0 * s[4], -dz, normal); + backFace.seal(true); + + backSide.seal(true); + frontSide.seal(true); + + /* finish outward face */ + sincos(da * 1f, s, 1, c, 1); + u = r2 * c[1] - r1 * c[4]; + v = r2 * s[1] - r1 * s[4]; + len = (float)Math.sqrt(u * u + v * v); + u /= len; + v /= len; + normal[0] = v; + normal[1] = -u; + normal[2] = 0.0f; + vert(outwardFace, r1 * c[4], r1 * s[4], dz, normal); + vert(outwardFace, r1 * c[4], r1 * s[4], -dz, normal); + outwardFace.seal(true); + + /* finish inside radius cylinder */ + normal[0] = c[4] * -1.0f; + normal[1] = s[4] * -1.0f; + normal[2] = 0.0f; + vert(insideRadiusCyl, r0 * c[4], r0 * s[4], -dz, normal); + vert(insideRadiusCyl, r0 * c[4], r0 * s[4], dz, normal); + insideRadiusCyl.seal(true); + } + + static void vert(GLArrayDataServer array, float x, float y, float z, float n[]) { + array.putf(x); + array.putf(y); + array.putf(z); + array.putf(n[0]); + array.putf(n[1]); + array.putf(n[2]); + } + + static void sincos(float x, float sin[], int sinIdx, float cos[], int cosIdx) { + sin[sinIdx] = (float) Math.sin(x); + cos[cosIdx] = (float) Math.cos(x); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java new file mode 100644 index 000000000..dfac46482 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -0,0 +1,224 @@ +/** + * Copyright (C) 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. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es1; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import com.jogamp.newt.Window; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTMouseAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; + +/** + * GearsES1.java <BR> + * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P> + */ +public class GearsES1 implements GLEventListener { + private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; + + private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private GearsObject gear1=null, gear2=null, gear3=null; + private float angle = 0.0f; + private int swapInterval; + + private int prevMouseX, prevMouseY; + + public GearsES1(int swapInterval) { + this.swapInterval = swapInterval; + } + + public GearsES1() { + this.swapInterval = 1; + } + + public void init(GLAutoDrawable drawable) { + System.err.println("Gears: Init: "+drawable); + // Use debug pipeline + // drawable.setGL(new DebugGL(drawable.getGL())); + + GL _gl = drawable.getGL(); + // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/); + GL2ES1 gl = _gl.getGL2ES1(); + + System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); + System.err.println("INIT GL IS: " + gl.getClass().getName()); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + + gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0); + gl.glEnable(GL.GL_CULL_FACE); + gl.glEnable(GL2ES1.GL_LIGHTING); + gl.glEnable(GL2ES1.GL_LIGHT0); + gl.glEnable(GL2ES1.GL_DEPTH_TEST); + + /* make the gears */ + if(null == gear1) { + gear1 = new GearsObjectES1(1.0f, 4.0f, 1.0f, 20, 0.7f); + System.err.println("gear1 created: "+gear1); + } else { + System.err.println("gear1 reused: "+gear1); + } + + if(null == gear2) { + gear2 = new GearsObjectES1(0.5f, 2.0f, 2.0f, 10, 0.7f); + System.err.println("gear2 created: "+gear2); + } else { + System.err.println("gear2 reused: "+gear2); + } + + if(null == gear3) { + gear3 = new GearsObjectES1(1.3f, 2.0f, 0.5f, 10, 0.7f); + System.err.println("gear3 created: "+gear3); + } else { + System.err.println("gear3 reused: "+gear3); + } + + gl.glEnable(GL2ES1.GL_NORMALIZE); + + // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); + MouseListener gearsMouse = new GearsMouseAdapter(); + KeyListener gearsKeys = new GearsKeyAdapter(); + + if (drawable instanceof Window) { + Window window = (Window) drawable; + window.addMouseListener(gearsMouse); + window.addKeyListener(gearsKeys); + } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) drawable; + new AWTMouseAdapter(gearsMouse).addTo(comp); + new AWTKeyAdapter(gearsKeys).addTo(comp); + } + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height); + GL2ES1 gl = drawable.getGL().getGL2ES1(); + + gl.setSwapInterval(swapInterval); + + float h = (float)height / (float)width; + + gl.glMatrixMode(GL2ES1.GL_PROJECTION); + + gl.glLoadIdentity(); + gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + gl.glMatrixMode(GL2ES1.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glTranslatef(0.0f, 0.0f, -40.0f); + } + + public void dispose(GLAutoDrawable drawable) { + System.err.println("Gears: Dispose"); + } + + public void display(GLAutoDrawable drawable) { + // Turn the gears' teeth + angle += 2.0f; + + // Get the GL corresponding to the drawable we are animating + GL2ES1 gl = drawable.getGL().getGL2ES1(); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT); + + gl.glNormal3f(0.0f, 0.0f, 1.0f); + + // Rotate the entire assembly of gears based on how the user + // dragged the mouse around + gl.glPushMatrix(); + gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + gear1.draw(gl, -3.0f, -2.0f, angle, GearsObject.red); + gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f, GearsObject.green); + gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f, GearsObject.blue); + + // Remember that every push needs a pop; this one is paired with + // rotating the entire gear assembly + gl.glPopMatrix(); + } + + + class GearsKeyAdapter extends KeyAdapter { + public void keyPressed(KeyEvent e) { + int kc = e.getKeyCode(); + if(KeyEvent.VK_LEFT == kc) { + view_roty -= 1; + } else if(KeyEvent.VK_RIGHT == kc) { + view_roty += 1; + } else if(KeyEvent.VK_UP == kc) { + view_rotx -= 1; + } else if(KeyEvent.VK_DOWN == kc) { + view_rotx += 1; + } + } + } + + class GearsMouseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent e) { + prevMouseX = e.getX(); + prevMouseY = e.getY(); + } + + public void mouseReleased(MouseEvent e) { + } + + public void mouseDragged(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + int width=0, height=0; + Object source = e.getSource(); + if(source instanceof Window) { + Window window = (Window) source; + width=window.getWidth(); + height=window.getHeight(); + } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) source; + width=comp.getWidth(); + height=comp.getHeight(); + } else { + throw new RuntimeException("Event source neither Window nor Component: "+source); + } + float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); + float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); + + prevMouseX = x; + prevMouseY = y; + + view_rotx += thetaX; + view_roty += thetaY; + } + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java new file mode 100644 index 000000000..0da2b5496 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 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. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es1; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.fixedfunc.GLPointerFunc; + + +import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; +import com.jogamp.opengl.util.GLArrayDataServer; + +/** + * GearsObjectES1.java <BR> + * author: Brian Paul (converted to Java by Sven Gothel) <P> + */ +public class GearsObjectES1 extends GearsObject { + + public GearsObjectES1(float inner_radius, float outer_radius, float width, + int teeth, float tooth_depth) { + super(inner_radius, outer_radius, width, teeth, tooth_depth); + } + + @Override + public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, + int components) { + array.addFixedSubArray(GLPointerFunc.GL_VERTEX_ARRAY, 3); + array.addFixedSubArray(GLPointerFunc.GL_NORMAL_ARRAY, 3); + } + + private void draw(GL2ES1 gl, GLArrayDataServer array, int mode) { + array.enableBuffer(gl, true); + gl.glDrawArrays(mode, 0, array.getElementCount()); + array.enableBuffer(gl, false); + } + + @Override + public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) { + GL2ES1 gl = _gl.getGL2ES1(); + gl.glPushMatrix(); + gl.glTranslatef(x, y, 0f); + gl.glRotatef(angle, 0f, 0f, 1f); + gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, color); + + gl.glShadeModel(GL2ES1.GL_FLAT); + draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); + draw(gl, frontSide, GL.GL_TRIANGLES); + draw(gl, backFace, GL.GL_TRIANGLE_STRIP); + draw(gl, backSide, GL.GL_TRIANGLES); + draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP); + gl.glShadeModel(GL2ES1.GL_SMOOTH); + draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP); + gl.glPopMatrix(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquare.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java index 5b7f1d12a..9c74ddce0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquare.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java @@ -10,7 +10,7 @@ import javax.media.nativewindow.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.glsl.fixedfunc.*; -public class RedSquare implements GLEventListener { +public class RedSquareES1 implements GLEventListener { public static boolean glDebugEmu = false; public static boolean glDebug = false ; @@ -25,11 +25,11 @@ public class RedSquare implements GLEventListener { GLU glu = null; - public RedSquare() { + public RedSquareES1() { this(false); } - public RedSquare(boolean debug) { + public RedSquareES1(boolean debug) { this.debug = debug; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/newt/TestGearsGL2ES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java index ffba7c050..86f63cb2d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/newt/TestGearsGL2ES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 JogAmp Community. All rights reserved. + * Copyright 2011 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: @@ -26,7 +26,7 @@ * or implied, of JogAmp Community. */ -package com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt; +package com.jogamp.opengl.test.junit.jogl.demos.es1.newt; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -36,7 +36,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.GearsGL2ES1; +import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -46,17 +46,17 @@ import org.junit.BeforeClass; import org.junit.AfterClass; import org.junit.Test; -public class TestGearsGL2ES1NEWT extends UITestCase { +public class TestGearsES1NEWT extends UITestCase { static GLProfile glp; static int width, height; @BeforeClass public static void initClass() { GLProfile.initSingleton(true); - if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) { + /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) { // exact match glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1); - } else { + } else */ { // default device, somehow ES1 compatible glp = GLProfile.getGL2ES1(); } @@ -74,7 +74,7 @@ public class TestGearsGL2ES1NEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test"); - glWindow.addGLEventListener(new GearsGL2ES1()); + glWindow.addGLEventListener(new GearsES1()); Animator animator = new Animator(glWindow); QuitAdapter quitAdapter = new QuitAdapter(); @@ -131,6 +131,6 @@ public class TestGearsGL2ES1NEWT extends UITestCase { } catch (Exception ex) { ex.printStackTrace(); } } } - org.junit.runner.JUnitCore.main(TestGearsGL2ES1NEWT.class.getName()); + org.junit.runner.JUnitCore.main(TestGearsES1NEWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java new file mode 100644 index 000000000..6d551144e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -0,0 +1,222 @@ +/** + * Copyright (C) 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. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; +import java.nio.FloatBuffer; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLUniformData; + +/** + * GearsES2.java <BR> + * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P> + */ +public class GearsES2 implements GLEventListener { + private final FloatBuffer lightPos = Buffers.newDirectFloatBuffer( new float[] { 5.0f, 5.0f, 10.0f } ); + + private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private GearsObject gear1=null, gear2=null, gear3=null; + private float angle = 0.0f; + private int swapInterval; + + private int prevMouseX, prevMouseY; + + public GearsES2(int swapInterval) { + this.swapInterval = swapInterval; + } + + public GearsES2() { + this.swapInterval = 1; + } + + ShaderState st; + PMVMatrix pmvMatrix; + GLUniformData pmvMatrixUniform; + GLUniformData colorU; + + public void init(GLAutoDrawable drawable) { + System.err.println("Gears: Init: "+drawable); + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); + System.err.println("INIT GL IS: " + gl.getClass().getName()); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + + gl.glEnable(GL.GL_CULL_FACE); + gl.glEnable(GL.GL_DEPTH_TEST); + + st = new ShaderState(); + st.setVerbose(true); + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, this.getClass(), + "shader", "shader/bin", "gears"); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, this.getClass(), + "shader", "shader/bin", "gears"); + final ShaderProgram sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + st.attachShaderProgram(gl, sp0); + st.useProgram(gl, true); + // Use debug pipeline + // drawable.setGL(new DebugGL(drawable.getGL())); + + pmvMatrix = new PMVMatrix(); + pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + GLUniformData lightU = new GLUniformData("lightPos", 3, lightPos); + st.ownUniform(lightU); + st.uniform(gl, lightU); + + colorU = new GLUniformData("color", 4, GearsObject.red); + st.ownUniform(colorU); + st.uniform(gl, colorU); + gear1 = new GearsObjectES2(1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + gear2 = new GearsObjectES2(0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + gear3 = new GearsObjectES2(1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + + // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); + MouseListener gearsMouse = new GearsMouseAdapter(); + KeyListener gearsKeys = new GearsKeyAdapter(); + + if (drawable instanceof Window) { + Window window = (Window) drawable; + window.addMouseListener(gearsMouse); + window.addKeyListener(gearsKeys); + } /* else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) drawable; + new AWTMouseAdapter(gearsMouse).addTo(comp); + new AWTKeyAdapter(gearsKeys).addTo(comp); + } */ + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height); + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + gl.setSwapInterval(swapInterval); + + float h = (float)height / (float)width; + + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f); + st.uniform(gl, pmvMatrixUniform); + } + + public void dispose(GLAutoDrawable drawable) { + System.err.println("Gears: Dispose"); + } + + public void display(GLAutoDrawable drawable) { + // Turn the gears' teeth + angle += 2.0f; + + // Get the GL corresponding to the drawable we are animating + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); + + pmvMatrix.glPushMatrix(); + pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); + pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); + pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + + gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f, GearsObject.red); + gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green); + gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue); + pmvMatrix.glPopMatrix(); + } + + class GearsKeyAdapter extends KeyAdapter { + public void keyPressed(KeyEvent e) { + int kc = e.getKeyCode(); + if(KeyEvent.VK_LEFT == kc) { + view_roty -= 1; + } else if(KeyEvent.VK_RIGHT == kc) { + view_roty += 1; + } else if(KeyEvent.VK_UP == kc) { + view_rotx -= 1; + } else if(KeyEvent.VK_DOWN == kc) { + view_rotx += 1; + } + } + } + + class GearsMouseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent e) { + prevMouseX = e.getX(); + prevMouseY = e.getY(); + } + + public void mouseReleased(MouseEvent e) { + } + + public void mouseDragged(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + int width=0, height=0; + Object source = e.getSource(); + if(source instanceof Window) { + Window window = (Window) source; + width=window.getWidth(); + height=window.getHeight(); + } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { + java.awt.Component comp = (java.awt.Component) source; + width=comp.getWidth(); + height=comp.getHeight(); + } else { + throw new RuntimeException("Event source neither Window nor Component: "+source); + } + float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); + float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); + + prevMouseX = x; + prevMouseY = y; + + view_rotx += thetaX; + view_roty += thetaY; + } + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java new file mode 100644 index 000000000..660218e6f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java @@ -0,0 +1,93 @@ +/** + * Copyright (C) 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. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLUniformData; + + +import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderState; + +/** + * GearsObjectES2.java <BR> + * author: Brian Paul (converted to Java by Sven Gothel) <P> + */ +public class GearsObjectES2 extends GearsObject { + final ShaderState st; + final PMVMatrix pmvMatrix; + final GLUniformData pmvMatrixUniform; + final GLUniformData colorUniform; + + public GearsObjectES2(float inner_radius, float outer_radius, float width, + int teeth, float tooth_depth, + PMVMatrix pmvMatrix, + GLUniformData pmvMatrixUniform, + GLUniformData colorUniform) + { + super(inner_radius, outer_radius, width, teeth, tooth_depth); + this.st = ShaderState.getCurrentShaderState(); + this.pmvMatrix = pmvMatrix; + this.pmvMatrixUniform = pmvMatrixUniform; + this.colorUniform = colorUniform; + } + + @Override + public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, + int components) { + final ShaderState st = ShaderState.getCurrentShaderState(); + array.addGLSLSubArray(st, "vertices", 3); + array.addGLSLSubArray(st, "normals", 3); + } + + private void draw(GL2ES2 gl, GLArrayDataServer array, int mode) { + array.enableBuffer(gl, true); + gl.glDrawArrays(mode, 0, array.getElementCount()); + array.enableBuffer(gl, false); + } + + @Override + public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) { + GL2ES2 gl = _gl.getGL2ES2(); + pmvMatrix.glPushMatrix(); + pmvMatrix.glTranslatef(x, y, 0f); + pmvMatrix.glRotatef(angle, 0f, 0f, 1f); + pmvMatrix.update(); + st.uniform(gl, pmvMatrixUniform); + + colorUniform.setData(color); + st.uniform(gl, colorUniform); + + draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); + draw(gl, frontSide, GL.GL_TRIANGLES); + draw(gl, backFace, GL.GL_TRIANGLE_STRIP); + draw(gl, backSide, GL.GL_TRIANGLES); + draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP); + draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP); + + pmvMatrix.glPopMatrix(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquare0.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index d38a60ea6..544ec4af5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquare0.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -42,7 +42,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLUniformData; import org.junit.Assert; -public class RedSquare0 implements GLEventListener { +public class RedSquareES2 implements GLEventListener { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream pbaos = new PrintStream(baos); GLSLSimpleProgram myShader; @@ -82,18 +82,10 @@ public class RedSquare0 implements GLEventListener { { // Fill them up FloatBuffer verticeb = (FloatBuffer) vertices.getBuffer(); - verticeb.put(-2); - verticeb.put(2); - verticeb.put(0); - verticeb.put(2); - verticeb.put(2); - verticeb.put(0); - verticeb.put(-2); - verticeb.put(-2); - verticeb.put(0); - verticeb.put(2); - verticeb.put(-2); - verticeb.put(0); + verticeb.put(-2); verticeb.put( 2); verticeb.put( 0); + verticeb.put( 2); verticeb.put( 2); verticeb.put( 0); + verticeb.put(-2); verticeb.put(-2); verticeb.put( 0); + verticeb.put( 2); verticeb.put(-2); verticeb.put( 0); } buffer.flip(); vertices.setLocation(mgl_Vertex); @@ -111,22 +103,10 @@ public class RedSquare0 implements GLEventListener { { // Fill them up FloatBuffer colorb = (FloatBuffer) colors.getBuffer(); - colorb.put(1); - colorb.put(0); - colorb.put(0); - colorb.put(1); - colorb.put(0); - colorb.put(0); - colorb.put(1); - colorb.put(1); - colorb.put(1); - colorb.put(0); - colorb.put(0); - colorb.put(1); - colorb.put(1); - colorb.put(0); - colorb.put(0); - colorb.put(1); + colorb.put(1); colorb.put(0); colorb.put(0); colorb.put(1); + colorb.put(0); colorb.put(0); colorb.put(1); colorb.put(1); + colorb.put(1); colorb.put(0); colorb.put(0); colorb.put(1); + colorb.put(1); colorb.put(0); colorb.put(0); colorb.put(1); } buffer.flip(); colors.setLocation(mgl_Color); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp new file mode 100644 index 000000000..be2ec6843 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp @@ -0,0 +1,50 @@ +// Copyright (C) 2011 JogAmp Community. All rights reserved. +// Details see GearsES2.java + +#ifdef GL_ES + #define MEDIUMP mediump + #define HIGHP highp +#else + #define MEDIUMP + #define HIGHP +#endif + +uniform MEDIUMP vec4 color; + +varying MEDIUMP vec3 normal; +varying MEDIUMP vec4 position; +varying MEDIUMP vec3 lightDir; +varying MEDIUMP float attenuation; +varying MEDIUMP vec3 cameraDir; + +// Defining The Material Colors +const MEDIUMP vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0); // orig default +const MEDIUMP vec4 matDiffuse = vec4(0.8, 0.8, 0.8, 1.0); // orig default +// const MEDIUMP vec4 matSpecular = vec4(0.0, 0.0, 0.0, 1.0); // orig default +const MEDIUMP vec4 matSpecular = vec4(0.8, 0.8, 0.8, 1.0); +// const MEDIUMP float matShininess = 0.0; // orig default +const MEDIUMP float matShininess = 0.5; + +void main() +{ + MEDIUMP float lambertTerm = dot(normal, lightDir); + + MEDIUMP vec4 ambient = color * matAmbient; + MEDIUMP vec4 diffuse = color * lambertTerm * attenuation * matDiffuse; + MEDIUMP vec4 specular = vec4(0.0); + if (lambertTerm > 0.0) { + float NdotHV; + /* + MEDIUMP vec3 halfDir; + halfDir = normalize (lightDir + cameraDir); + NdotHV = max(0.0, dot(normal, halfDir)); + */ + vec3 E = normalize(-position.xyz); + vec3 R = reflect(-lightDir, normal); + NdotHV = max(0.0, dot(R, E)); + + specular += color * pow(NdotHV, matShininess) * attenuation * matSpecular; + } + + gl_FragColor = ambient + diffuse + specular ; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp new file mode 100644 index 000000000..0e417290c --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp @@ -0,0 +1,48 @@ +// Copyright (C) 2011 JogAmp Community. All rights reserved. +// Details see GearsES2.java + +#ifdef GL_ES + #define MEDIUMP mediump + #define HIGHP highp +#else + #define MEDIUMP + #define HIGHP +#endif + +uniform MEDIUMP mat4 pmvMatrix[4]; // P, Mv, Mvi and Mvit +uniform MEDIUMP vec3 lightPos; + +attribute MEDIUMP vec4 vertices; +attribute MEDIUMP vec4 normals; + +varying MEDIUMP vec3 normal; +varying MEDIUMP vec4 position; +varying MEDIUMP vec3 lightDir; +varying MEDIUMP float attenuation; +varying MEDIUMP vec3 cameraDir; + +const MEDIUMP float constantAttenuation = 0.5; // 1.0; +const MEDIUMP float linearAttenuation = 0.001; // 0.0; +const MEDIUMP float quadraticAttenuation= 0.0002; // 0.0; + +void main(void) +{ + // Transforming The Vertex Position To ModelView-Space + position = pmvMatrix[1] * vertices; // vertex eye position + + // incl. projection + gl_Position = pmvMatrix[0] * position; + + // Transforming The Normal To ModelView-Space + normal = normalize((pmvMatrix[3] * normals).xyz); + + // Calculating The Vector From The Vertex Position To The Light Position + lightDir = lightPos - position.xyz; + MEDIUMP float d = length(lightDir); + attenuation = 1.0 / ( + constantAttenuation + + linearAttenuation * d + + quadraticAttenuation * d * d ); + lightDir = normalize(lightDir); + cameraDir = normalize((pmvMatrix[2] * vec4(0,0,0,1.0)).xyz - vertices.xyz); +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java deleted file mode 100644 index 0997ba4a8..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java +++ /dev/null @@ -1,441 +0,0 @@ - -package com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears; - -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; -import com.jogamp.opengl.util.ImmModeSink; -import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil; - -import com.jogamp.newt.Window; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.awt.AWTKeyAdapter; -import com.jogamp.newt.event.awt.AWTMouseAdapter; - -/** - * Gears.java <BR> - * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P> - * - * This version is equal to Brian Paul's version 1.2 1999/10/21 - */ - -public class GearsGL2ES1 implements GLEventListener { - private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; - private final float red[] = { 0.8f, 0.1f, 0.0f, 0.7f }; - private final float green[] = { 0.0f, 0.8f, 0.2f, 0.7f }; - private final float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f }; - - private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; - private GearBuffers gear1=null, gear2=null, gear3=null; - private float angle = 0.0f; - private int swapInterval; - - private boolean mouseRButtonDown = false; - private int prevMouseX, prevMouseY; - - public GearsGL2ES1(int swapInterval) { - this.swapInterval = swapInterval; - } - - public GearsGL2ES1() { - this.swapInterval = 1; - } - - public void init(GLAutoDrawable drawable) { - System.err.println("Gears: Init: "+drawable); - // Use debug pipeline - // drawable.setGL(new DebugGL(drawable.getGL())); - - GL _gl = drawable.getGL(); - // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/); - GL2ES1 gl = _gl.getGL2ES1(); - - System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); - System.err.println("INIT GL IS: " + gl.getClass().getName()); - System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); - System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); - System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); - - gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0); - gl.glEnable(GL.GL_CULL_FACE); - gl.glEnable(GL2ES1.GL_LIGHTING); - gl.glEnable(GL2ES1.GL_LIGHT0); - gl.glEnable(GL2ES1.GL_DEPTH_TEST); - - /* make the gears */ - if(null == gear1) { - gear1 = gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f); - System.err.println("gear1 created: "+gear1); - } else { - System.err.println("gear1 reused: "+gear1); - } - - if(null == gear2) { - gear2 = gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f); - System.err.println("gear2 created: "+gear2); - } else { - System.err.println("gear2 reused: "+gear2); - } - - if(null == gear3) { - gear3 = gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f); - System.err.println("gear3 created: "+gear3); - } else { - System.err.println("gear3 reused: "+gear3); - } - - gl.glEnable(GL2ES1.GL_NORMALIZE); - - // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); - MouseListener gearsMouse = new GearsMouseAdapter(); - KeyListener gearsKeys = new GearsKeyAdapter(); - - if (drawable instanceof Window) { - Window window = (Window) drawable; - window.addMouseListener(gearsMouse); - window.addKeyListener(gearsKeys); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; - new AWTMouseAdapter(gearsMouse).addTo(comp); - new AWTKeyAdapter(gearsKeys).addTo(comp); - } - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height); - GL2ES1 gl = drawable.getGL().getGL2ES1(); - - gl.setSwapInterval(swapInterval); - - float h = (float)height / (float)width; - - gl.glMatrixMode(GL2ES1.GL_PROJECTION); - - gl.glLoadIdentity(); - gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); - gl.glMatrixMode(GL2ES1.GL_MODELVIEW); - gl.glLoadIdentity(); - gl.glTranslatef(0.0f, 0.0f, -40.0f); - } - - public void dispose(GLAutoDrawable drawable) { - System.err.println("Gears: Dispose"); - } - - public void display(GLAutoDrawable drawable) { - // Turn the gears' teeth - angle += 2.0f; - - // Get the GL corresponding to the drawable we are animating - GL2ES1 gl = drawable.getGL().getGL2ES1(); - - gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - // Special handling for the case where the GLJPanel is translucent - // and wants to be composited with other Java 2D content - if (GLProfile.isAWTAvailable() && - (drawable instanceof javax.media.opengl.awt.GLJPanel) && - !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && - ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { - gl.glClear(GL2ES1.GL_DEPTH_BUFFER_BIT); - } else { - gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT); - } - - gl.glNormal3f(0.0f, 0.0f, 1.0f); - - // Rotate the entire assembly of gears based on how the user - // dragged the mouse around - gl.glPushMatrix(); - gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); - gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); - gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - - final boolean disableBufferAfterDraw = true; - - // Place the first gear and call its display list - gl.glPushMatrix(); - gl.glTranslatef(-3.0f, -2.0f, 0.0f); - gl.glRotatef(angle, 0.0f, 0.0f, 1.0f); - gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, red, 0); - gear1.draw(gl, disableBufferAfterDraw); - gl.glPopMatrix(); - - // Place the second gear and call its display list - gl.glPushMatrix(); - gl.glTranslatef(3.1f, -2.0f, 0.0f); - gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); - gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, green, 0); - gear2.draw(gl, disableBufferAfterDraw); - gl.glPopMatrix(); - - // Place the third gear and call its display list - gl.glPushMatrix(); - gl.glTranslatef(-3.1f, 4.2f, 0.0f); - gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); - gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, blue, 0); - gear3.draw(gl, disableBufferAfterDraw); - gl.glPopMatrix(); - - // Remember that every push needs a pop; this one is paired with - // rotating the entire gear assembly - gl.glPopMatrix(); - } - - static class GearBuffers { - public final ImmModeSink frontFace; - public final ImmModeSink frontSide; - public final ImmModeSink backFace; - public final ImmModeSink backSide; - public final ImmModeSink outwardFace; - public final ImmModeSink insideRadiusCyl; - - public GearBuffers( - ImmModeSink frontFace, - ImmModeSink frontSide, - ImmModeSink backFace, - ImmModeSink backSide, - ImmModeSink outwardFace, - ImmModeSink insideRadiusCyl) { - this.frontFace = frontFace; - this.frontSide = frontSide; - this.backFace = backFace; - this.backSide = backSide; - this.outwardFace = outwardFace; - this.insideRadiusCyl = insideRadiusCyl; - } - - public void draw(GL2ES1 gl, boolean disableBufferAfterDraw) { - gl.glShadeModel(GL2ES1.GL_FLAT); - frontFace.draw(gl, disableBufferAfterDraw); - frontSide.draw(gl, disableBufferAfterDraw); - backFace.draw(gl, disableBufferAfterDraw); - backSide.draw(gl, disableBufferAfterDraw); - outwardFace.draw(gl, disableBufferAfterDraw); - gl.glShadeModel(GL2ES1.GL_SMOOTH); - insideRadiusCyl.draw(gl, disableBufferAfterDraw); - } - } - - public static GearBuffers gear(GL2ES1 gl, - float inner_radius, - float outer_radius, - float width, - int teeth, - float tooth_depth) - { - final float dz = width * 0.5f; - int i; - float r0, r1, r2; - float angle, da; - float u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.0f; - r2 = outer_radius + tooth_depth / 2.0f; - - da = 2.0f * (float) Math.PI / teeth / 4.0f; - - /* draw front face */ - ImmModeSink vboFrontFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2, - /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT, - /* normal */ 0, GL.GL_BYTE, /* texture */ 0, GL.GL_FLOAT); - vboFrontFace.glBegin(GL.GL_TRIANGLE_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz); - vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz); - vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz); - vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz); - } - vboFrontFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz); - vboFrontFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), dz); - vboFrontFace.glEnd(gl, false /* immediate */); - - /* draw front sides of teeth */ - ImmModeSink vboFrontSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth, - /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT, - /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT); - vboFrontSide.glBegin(GL.GL_TRIANGLES); - for (i = 0; i < teeth; i++) { - // QUAD [s0..s3] -> 2x TRIs - angle = i * 2.0f * (float) Math.PI / teeth; - // s0 - vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz); - // s1 - vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), dz); - // s2 - vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz); - - // s0 - vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz); - // s2 - vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz); - // s3 - vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz); - } - vboFrontSide.glEnd(gl, false /* immediate */); - - /* draw back face */ - ImmModeSink vboBackFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2, - /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT, - /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT); - vboBackFace.glBegin(GL.GL_TRIANGLE_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - vboBackFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz); - vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz); - vboBackFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz); - vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz); - } - vboBackFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), -dz); - vboBackFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz); - vboBackFace.glEnd(gl, false /* immediate */); - - /* draw back sides of teeth */ - ImmModeSink vboBackSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth, - /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT, - /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT); - vboBackSide.glBegin(GL.GL_TRIANGLES); - for (i = 0; i < teeth; i++) { - // QUAD [s0..s3] -> 2x TRIs - angle = i * 2.0f * (float) Math.PI / teeth; - // s0 - vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz); - // s1 - vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz); - // s2 - vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz); - - // s0 - vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz); - // s2 - vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz); - // s3 - vboBackSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz); - } - vboBackSide.glEnd(gl, false /* immediate */); - - /* draw outward faces of teeth */ - ImmModeSink vboOutwardFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*4*teeth, - /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT, - /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT); - vboOutwardFace.glBegin(GL.GL_TRIANGLE_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle); - v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle); - len = (float)Math.sqrt(u * u + v * v); - u /= len; - v /= len; - - vboOutwardFace.glNormal3f(v, -u, 0.0f); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz); - - vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz); - - u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da); - v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da); - vboOutwardFace.glNormal3f(v, -u, 0.0f); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz); - vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz); - - vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz); - vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz); - } - vboOutwardFace.glEnd(gl, false /* immediate */); - - /* draw inside radius cylinder */ - ImmModeSink vboInsideRadiusCyl = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 2*teeth+2, - /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT, - /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT); - vboInsideRadiusCyl.glBegin(GL.GL_TRIANGLE_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f); - vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz); - vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz); - } - vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(0f), -(float)Math.sin(0f), 0.0f); - vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz); - vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz); - vboInsideRadiusCyl.glEnd(gl, false /* immediate */); - return new GearBuffers(vboFrontFace, vboFrontSide, vboBackFace, vboBackSide, vboOutwardFace, vboInsideRadiusCyl); - } - - class GearsKeyAdapter extends KeyAdapter { - public void keyPressed(KeyEvent e) { - int kc = e.getKeyCode(); - if(KeyEvent.VK_LEFT == kc) { - view_roty -= 1; - } else if(KeyEvent.VK_RIGHT == kc) { - view_roty += 1; - } else if(KeyEvent.VK_UP == kc) { - view_rotx -= 1; - } else if(KeyEvent.VK_DOWN == kc) { - view_rotx += 1; - } - } - } - - class GearsMouseAdapter extends MouseAdapter { - public void mousePressed(MouseEvent e) { - prevMouseX = e.getX(); - prevMouseY = e.getY(); - if ((e.getModifiers() & e.BUTTON3_MASK) != 0) { - mouseRButtonDown = true; - } - } - - public void mouseReleased(MouseEvent e) { - if ((e.getModifiers() & e.BUTTON3_MASK) != 0) { - mouseRButtonDown = false; - } - } - - public void mouseDragged(MouseEvent e) { - int x = e.getX(); - int y = e.getY(); - int width=0, height=0; - Object source = e.getSource(); - if(source instanceof Window) { - Window window = (Window) source; - width=window.getWidth(); - height=window.getHeight(); - } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) source; - width=comp.getWidth(); - height=comp.getHeight(); - } else { - throw new RuntimeException("Event source neither Window nor Component: "+source); - } - float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); - float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); - - prevMouseX = x; - prevMouseY = y; - - view_rotx += thetaX; - view_roty += thetaY; - } - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java index e75f4ebe3..504691fbe 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java @@ -55,7 +55,7 @@ public class GLSLMiscHelper { Assert.assertEquals(data.enabled()?GL.GL_TRUE:GL.GL_FALSE, qi[0]); gl.glGetVertexAttribiv(data.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0); Assert.assertEquals(data.getVBOName(), qi[0]); - Assert.assertEquals(data.getByteSize(), gl.glGetBufferSize(data.getVBOName())); + Assert.assertEquals(data.getSizeInBytes(), gl.glGetBufferSize(data.getVBOName())); } public static void pause(long ms) throws InterruptedException { @@ -127,7 +127,7 @@ public class GLSLMiscHelper { vertices0.seal(gl, true); Assert.assertTrue(vertices0.isVBOWritten()); Assert.assertTrue(vertices0.sealed()); - Assert.assertEquals(4, vertices0.getElementNumber()); + Assert.assertEquals(4, vertices0.getElementCount()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(vertices0.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); validateGLArrayDataServerState(gl, st, vertices0); @@ -147,7 +147,7 @@ public class GLSLMiscHelper { vertices1.seal(gl, true); Assert.assertTrue(vertices1.isVBOWritten()); Assert.assertTrue(vertices1.sealed()); - Assert.assertEquals(4, vertices1.getElementNumber()); + Assert.assertEquals(4, vertices1.getElementCount()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(vertices1.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); validateGLArrayDataServerState(gl, st, vertices1); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java index f3af56fb3..2785a2701 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java @@ -33,7 +33,7 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -68,9 +68,9 @@ public class TestFBOMRTNEWT01 extends UITestCase { final ShaderState st = new ShaderState(); // st.setVerbose(true); - final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "fbo-mrt-1"); - final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "fbo-mrt-1"); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); @@ -81,9 +81,9 @@ public class TestFBOMRTNEWT01 extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); st.attachShaderProgram(gl, sp0); - final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "fbo-mrt-2"); - final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "fbo-mrt-2"); final ShaderProgram sp1 = new ShaderProgram(); sp1.add(gl, vp1, System.err); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java index 484734b28..b8551527e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java @@ -32,7 +32,7 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -70,9 +70,9 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // test code .. final ShaderState st = new ShaderState(); - final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); final ShaderProgram sp = new ShaderProgram(); @@ -195,9 +195,9 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // test code .. final ShaderState st = new ShaderState(); - final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); final ShaderProgram sp = new ShaderProgram(); @@ -284,9 +284,9 @@ public class TestGLSLShaderState01NEWT extends UITestCase { // test code .. final ShaderState st = new ShaderState(); - final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); final ShaderProgram sp = new ShaderProgram(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java index 2ecc3b30d..f71b7bea7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java @@ -32,7 +32,7 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -78,11 +78,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // test code .. final ShaderState st = new ShaderState(); - final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader2"); final ShaderProgram sp1 = new ShaderProgram(); @@ -243,11 +243,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // test code .. final ShaderState st = new ShaderState(); - final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader"); - final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "RedSquareShader2"); final ShaderProgram sp1 = new ShaderProgram(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java index ed9fbd455..b683cb2e7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java @@ -28,7 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.glsl; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.GLSLSimpleProgram; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -115,7 +115,7 @@ public class TestGLSLSimple01NEWT extends UITestCase { window.setSize(800, 600); window.setVisible(true); Assert.assertTrue(window.isNativeValid()); - window.addGLEventListener(new RedSquare0()); + window.addGLEventListener(new RedSquareES2()); Animator animator = new Animator(window); animator.setUpdateFPSFrames(1, null); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java index cc0ec4601..1ea9c731a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java @@ -34,7 +34,7 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -42,7 +42,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import java.io.IOException; import java.nio.FloatBuffer; -import javax.media.nativewindow.util.DimensionReadOnly; +import javax.media.nativewindow.util.DimensionImmutable; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLDrawable; @@ -67,9 +67,9 @@ public class TestRulerNEWT01 extends UITestCase { // test code .. final ShaderState st = new ShaderState(); - final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class, + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "default"); - final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class, + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class, "shader", "shader/bin", "ruler"); final ShaderProgram sp0 = new ShaderProgram(); @@ -100,8 +100,8 @@ public class TestRulerNEWT01 extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); final MonitorMode mmode = winctx.window.getScreen().getCurrentScreenMode().getMonitorMode(); - final DimensionReadOnly sdim = mmode.getScreenSizeMM(); - final DimensionReadOnly spix = mmode.getSurfaceSize().getResolution(); + final DimensionImmutable sdim = mmode.getScreenSizeMM(); + final DimensionImmutable spix = mmode.getSurfaceSize().getResolution(); final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2)); final FloatBuffer rulerPixFreqV = (FloatBuffer) rulerPixFreq.getBuffer(); rulerPixFreqV.put(0, (float)spix.getWidth() / (float)sdim.getWidth() * 10.0f); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java index 8c315e97f..5bdef2869 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java @@ -62,7 +62,7 @@ public class ReadBuffer2Screen extends ReadBufferBase { if(null==readTextureVertices) { //readTextureVertices = GLArrayDataClient.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", // 2, GL.GL_FLOAT, true, 4); - readTextureVertices = GLArrayDataServer.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", 2, + readTextureVertices = GLArrayDataServer.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); readTextureVertices.setEnableAlways(enableBufferAlways); readTextureVertices.setVBOEnabled(enableBufferVBO); @@ -142,7 +142,7 @@ public class ReadBuffer2Screen extends ReadBufferBase { if(null!=readTextureCoords) { readTextureCoords.enableBuffer(gl, true); } - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, readTextureVertices.getElementNumber()); + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, readTextureVertices.getElementCount()); /** if(null!=readTextureCoords) { readTextureCoords.enableBuffer(gl, false); @@ -154,7 +154,7 @@ public class ReadBuffer2Screen extends ReadBufferBase { void updateTextureCoords(GL gl, boolean force) { if(force || null==readTextureCoords) { - readTextureCoords = GLArrayDataServer.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, "mgl_MultiTexCoord0", 2, + readTextureCoords = GLArrayDataServer.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); readTextureCoords.setEnableAlways(enableBufferAlways); readTextureCoords.setVBOEnabled(enableBufferVBO); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java index 40ea6848a..8b4d199e8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java @@ -46,7 +46,7 @@ import javax.media.opengl.*; import javax.media.nativewindow.*; import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import java.io.IOException; public class TestOffscreen01GLPBufferNEWT extends UITestCase { @@ -88,7 +88,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setVisible(true); - GLEventListener demo = new RedSquare(); + GLEventListener demo = new RedSquareES1(); WindowUtilNEWT.setDemoFields(demo, window, glWindow, false); glWindow.addGLEventListener(demo); @@ -182,7 +182,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { Assert.assertNotNull(glWindows[i]); glWindows[i].setVisible(true); - demos[i] = new RedSquare(); + demos[i] = new RedSquareES1(); WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false); glWindows[i].addGLEventListener(demos[i]); } @@ -235,7 +235,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { glWindows[i] = GLWindow.create(windows[i]); Assert.assertNotNull(glWindows[i]); glWindows[i].setVisible(true); - demos[i] = new RedSquare(); + demos[i] = new RedSquareES1(); WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false); glWindows[i].addGLEventListener(demos[i]); } @@ -287,7 +287,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { MouseListener ml=null; SurfaceUpdatedListener ul=null; - GLEventListener demo = new RedSquare(); + GLEventListener demo = new RedSquareES1(); Assert.assertNotNull(demo); WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java index cc6e9b26d..766f64d70 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java @@ -46,7 +46,7 @@ import javax.media.opengl.*; import javax.media.nativewindow.*; import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import java.io.IOException; public class TestOffscreen02BitmapNEWT extends UITestCase { @@ -97,7 +97,7 @@ public class TestOffscreen02BitmapNEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setVisible(true); - GLEventListener demo = new RedSquare(); + GLEventListener demo = new RedSquareES1(); WindowUtilNEWT.setDemoFields(demo, window, glWindow, false); glWindow.addGLEventListener(demo); @@ -145,7 +145,7 @@ public class TestOffscreen02BitmapNEWT extends UITestCase { MouseListener ml=null; SurfaceUpdatedListener ul=null; - GLEventListener demo = new RedSquare(); + GLEventListener demo = new RedSquareES1(); Assert.assertNotNull(demo); WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java index 79196bd4c..e23510e25 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -51,7 +51,7 @@ import org.junit.Test; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.util.*; @@ -93,7 +93,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase { // Create a window. GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setTitle("testNewtChildFocus"); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java index 1b65c8910..1947930c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java @@ -57,7 +57,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestListenerCom01AWT extends UITestCase { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java index 810539c90..9ad487bdf 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java @@ -46,7 +46,7 @@ import java.util.Iterator; import java.util.List; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionReadOnly; +import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.SurfaceSize; public class TestScreenMode00NEWT extends UITestCase { @@ -66,9 +66,9 @@ public class TestScreenMode00NEWT extends UITestCase { @Test public void testScreenModeInfo00() throws InterruptedException { - DimensionReadOnly res = new Dimension(640, 480); + DimensionImmutable res = new Dimension(640, 480); SurfaceSize surfsz = new SurfaceSize(res, 32); - DimensionReadOnly mm = new Dimension(500, 400); + DimensionImmutable mm = new Dimension(500, 400); MonitorMode mon = new MonitorMode(surfsz, mm, 60); ScreenMode sm_out = new ScreenMode(mon, 90); System.err.println("00 out: "+sm_out); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index f4aa44354..560d1ec7c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -43,7 +43,7 @@ import com.jogamp.newt.opengl.*; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01NEWT extends UITestCase { @@ -83,7 +83,7 @@ public class TestParenting01NEWT extends UITestCase { glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); glWindow1.setSize(640, 480); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -305,7 +305,7 @@ public class TestParenting01NEWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setTitle("testWindowParenting02ReparentTop2Win"); glWindow1.setSize(640, 480); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); screen1 = glWindow1.getScreen(); @@ -502,7 +502,7 @@ public class TestParenting01NEWT extends UITestCase { display1 = screen1.getDisplay(); glWindow1.setTitle("testWindowParenting03ReparentWin2Top"); glWindow1.setSize(640, 480); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java index 50461bba0..7e0f18f00 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java @@ -59,7 +59,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01aAWT extends UITestCase { @@ -90,7 +90,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -160,7 +160,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(false, glWindow1.isVisible()); Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -201,7 +201,7 @@ public class TestParenting01aAWT extends UITestCase { NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -239,7 +239,7 @@ public class TestParenting01aAWT extends UITestCase { NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -290,7 +290,7 @@ public class TestParenting01aAWT extends UITestCase { NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -347,7 +347,7 @@ public class TestParenting01aAWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java index 84edfc8ba..f929b6fbc 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java @@ -59,7 +59,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01bAWT extends UITestCase { @@ -94,7 +94,7 @@ public class TestParenting01bAWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java index 905d80925..c84655e23 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java @@ -58,7 +58,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting01cAWT extends UITestCase { @@ -88,7 +88,7 @@ public class TestParenting01cAWT extends UITestCase { Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); @@ -150,7 +150,7 @@ public class TestParenting01cAWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 949fb29df..ed6f9ea75 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -52,7 +52,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; public class TestParenting01cSwingAWT extends UITestCase { static int width, height; @@ -79,7 +79,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); Animator animator1 = new Animator(glWindow1); @@ -190,7 +190,7 @@ public class TestParenting01cSwingAWT extends UITestCase { Assert.assertEquals(false, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); Animator animator1 = new Animator(glWindow1); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java index b6e02d810..ba73ae6d9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java @@ -57,7 +57,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting02AWT extends UITestCase { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java index b9bd2d93d..89f70421f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java @@ -52,7 +52,7 @@ import com.jogamp.newt.opengl.*; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears; public class TestParenting02NEWT extends UITestCase { @@ -122,7 +122,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); glWindow1.addWindowListener(new TraceWindowAdapter()); - GLEventListener demo1 = new RedSquare(); + GLEventListener demo1 = new RedSquareES1(); setDemoFields(demo1, window1, glWindow1, false); // glWindow1.addGLEventListener(demo1); |