From 16c5ff859e1714be198432aaf4f5bd225e7f6d04 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 9 Apr 2010 02:21:59 +0200 Subject: Cleanup ant files, intro: build-common.xml used for all targets; Extracting build-junit.xml --- make/build-common.xml | 333 +++++++++++ make/build-jogl.xml | 614 ++++++--------------- make/build-junit.xml | 108 ++++ make/build-nativewindow.xml | 248 ++------- make/build-newt.xml | 211 ++----- make/build.xml | 119 ++-- make/versions.xml | 3 - .../opengl/test/junit/texture/awt/Texture1.java | 125 ----- .../texture/util/gl2/TextureGL2ListenerDraw1.java | 109 ---- .../test/junit/jogl/awt/texture/Texture1.java | 125 +++++ .../util/texture/gl2/TextureGL2ListenerDraw1.java | 109 ++++ 11 files changed, 978 insertions(+), 1126 deletions(-) create mode 100644 make/build-common.xml create mode 100644 make/build-junit.xml delete mode 100755 src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java delete mode 100755 src/jogl/junit/com/jogamp/opengl/test/junit/texture/util/gl2/TextureGL2ListenerDraw1.java create mode 100755 src/junit/com/jogamp/test/junit/jogl/awt/texture/Texture1.java create mode 100755 src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java diff --git a/make/build-common.xml b/make/build-common.xml new file mode 100644 index 000000000..bee69a5a9 --- /dev/null +++ b/make/build-common.xml @@ -0,0 +1,333 @@ + + + + + Common JOGL Stuff + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/build-jogl.xml b/make/build-jogl.xml index e8d37dd05..5381c2051 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -63,32 +63,13 @@ --> - - - - - + - - - - - - - - - - - - - - - - + @@ -207,109 +188,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + @@ -318,29 +220,23 @@ - - - - - - - + + + + - - - - - + + - - - - - - + + + + + + - + @@ -349,47 +245,26 @@ - + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - @@ -398,79 +273,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -487,26 +289,22 @@ - + - + - - + + - - - - - + @@ -530,10 +328,7 @@ - Initialize all parameters required for the build and create any - required directories. --> - - - - + @@ -544,33 +339,15 @@ - - + + - - - - - - - - - - - - - - @@ -635,7 +412,7 @@ - @@ -644,8 +421,8 @@ @@ -656,8 +433,8 @@ @@ -668,8 +445,8 @@ @@ -680,15 +457,15 @@ @@ -699,8 +476,8 @@ @@ -711,8 +488,8 @@ @@ -723,8 +500,8 @@ @@ -735,8 +512,8 @@ @@ -747,8 +524,8 @@ @@ -759,8 +536,8 @@ @@ -783,8 +560,8 @@ @@ -795,8 +572,8 @@ @@ -807,8 +584,8 @@ @@ -819,7 +596,7 @@ @@ -830,9 +607,9 @@ - - + @@ -843,9 +620,9 @@ - - + @@ -856,8 +633,8 @@ - @@ -866,7 +643,7 @@ - + @@ -877,7 +654,7 @@ - from the C GL headers. This involves setting the taskdef and creating - the classpath reference id then running the task on each header. --> - + - - - + + + - - - + + + - - - + + + @@ -960,8 +737,8 @@ @@ -1156,7 +933,7 @@ includes="com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncImpl.java" /> - + @@ -1193,7 +970,7 @@ @@ -1208,7 +985,7 @@ @@ -1224,7 +1001,7 @@ @@ -1238,7 +1015,7 @@ - - + + - - - + + + - - + + @@ -1600,7 +1377,7 @@ - + @@ -1639,32 +1416,32 @@ - + - - - - + + + + - + - - + + - - + + @@ -1691,7 +1468,7 @@ @@ -1715,7 +1492,7 @@ @@ -1727,71 +1504,71 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1799,44 +1576,44 @@ - + - + - + - + - + - + - + - + @@ -1850,7 +1627,7 @@ - + @@ -1860,7 +1637,7 @@ - + @@ -1871,25 +1648,25 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1944,29 +1721,29 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -2095,69 +1872,22 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + diff --git a/make/build-junit.xml b/make/build-junit.xml new file mode 100644 index 000000000..5b3aae8c2 --- /dev/null +++ b/make/build-junit.xml @@ -0,0 +1,108 @@ + + + + + JUNIT Tests JOGL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index b34ad3954..3cb7e7746 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -53,25 +53,13 @@ --> - - - - - + - - - - - - - - - + @@ -80,12 +68,7 @@ - - - - - @@ -107,109 +90,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - - - + - - + - - - + + - - - - - - - - - + + + + + - + @@ -217,31 +138,12 @@ - + - - - - - - - - - - - - - - - - - @@ -263,9 +165,6 @@ - required directories. --> - - - @@ -275,25 +174,7 @@ - - - - - - - - - - - - - - - + - + - - - + + + - - + + - - + + @@ -449,10 +330,10 @@ @@ -656,8 +537,8 @@ - - - + + + - - + + @@ -720,7 +601,7 @@ - + @@ -750,25 +631,25 @@ - - + + - + - - + + - - + + @@ -889,11 +770,11 @@ - + - + - + - + @@ -954,22 +835,11 @@ - - - - - - - - - - - - + - + - + diff --git a/make/build-newt.xml b/make/build-newt.xml index 782ff158d..d8f8c2b60 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -56,27 +56,13 @@ --> - - - - - + - - - - - - - - - - - + @@ -89,16 +75,14 @@ - - - - - + + + @@ -145,127 +129,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -288,9 +173,6 @@ - required directories. --> - - - @@ -300,7 +182,7 @@ - + @@ -311,9 +193,9 @@ @@ -324,10 +206,10 @@ @@ -531,8 +413,8 @@ - - + + - - - + + + - - + + @@ -621,7 +503,7 @@ - + @@ -629,18 +511,18 @@ - + - - + + - - + + @@ -661,14 +543,11 @@ - - - - + @@ -683,14 +562,11 @@ - - - - + @@ -800,7 +676,7 @@ - on the platform specific build targets. To circumvent any - errors, ensure that the source is built first. --> - + - + - + - + @@ -861,22 +737,11 @@ - - - - - - - - - - - - + - + - + diff --git a/make/build.xml b/make/build.xml index 54b6a8e67..206d46d34 100644 --- a/make/build.xml +++ b/make/build.xml @@ -1,33 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -51,42 +27,28 @@ - - - - - - - - - - - - - - + - + - + - + - - - - + + + @@ -100,36 +62,23 @@ - This must be called after all of the build targets complete. --> - - - - - - - - - - - - - - - - + + + - - - - + + + + - + - - + + @@ -139,8 +88,8 @@ - - + + @@ -148,7 +97,7 @@ basedir="${build}" includes="${archive.name}/**" /> - + @@ -157,20 +106,20 @@ - This must be called after all of the build targets complete. --> - + - - + @@ -185,9 +134,9 @@ - - - + + + @@ -203,7 +152,7 @@ source="1.4" maxmemory="512m" bottom="${javadoc.bottom}" > - + @@ -220,7 +169,7 @@ source="1.4" maxmemory="512m" bottom="${javadoc.bottom}" > - + @@ -238,7 +187,7 @@ source="1.4" maxmemory="512m" bottom="${javadoc.bottom}" > - + @@ -255,7 +204,7 @@ source="1.4" maxmemory="512m" bottom="${javadoc.bottom}" > - + diff --git a/make/versions.xml b/make/versions.xml index 0ee07bfe0..75c035f5a 100644 --- a/make/versions.xml +++ b/make/versions.xml @@ -19,7 +19,6 @@ official release builds and intermediate release builds, but commented out for nightly builds. --> - @@ -31,7 +30,6 @@ official release builds and intermediate release builds, but commented out for nightly builds. --> - @@ -44,6 +42,5 @@ official release builds and intermediate release builds, but commented out for nightly builds. --> - diff --git a/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java b/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java deleted file mode 100755 index 56d669756..000000000 --- a/src/jogl/junit/com/jogamp/opengl/test/junit/texture/awt/Texture1.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2010 Sven Gothel. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution 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. - * - * Neither the name Sven Gothel or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -package com.jogamp.opengl.test.junit.texture.awt; - -import com.jogamp.opengl.test.junit.texture.util.gl2.TextureGL2ListenerDraw1; - -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GL2; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureCoords; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; -import com.jogamp.opengl.util.texture.awt.AWTTextureIO; -import com.jogamp.opengl.util.Animator; - -import java.awt.AlphaComposite; -import java.awt.Color; -import java.awt.Frame; -import java.awt.GradientPaint; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class Texture1 { - Frame frame; - BufferedImage textureImage; - - @Before - public void init() { - // create base image - BufferedImage baseImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB); - Graphics2D g = baseImage.createGraphics(); - g.setPaint(new GradientPaint(0, 0, Color.CYAN, - baseImage.getWidth(), baseImage.getHeight(), Color.BLUE)); - g.fillRect(0, 0, baseImage.getWidth(), baseImage.getHeight()); - g.dispose(); - - // create texture image - int imageType = BufferedImage.TYPE_INT_RGB; - textureImage = new BufferedImage(baseImage.getWidth(), - baseImage.getHeight(), - imageType); - g = textureImage.createGraphics(); - g.setComposite(AlphaComposite.Src); - g.drawImage(baseImage, 0, 0, null); - g.dispose(); - - frame = new Frame("Texture Test"); - } - - @Test - public void test1() { - GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3)); - GLCanvas glCanvas = new GLCanvas(caps); - frame.add(glCanvas); - frame.setSize(512, 512); - - // create texture - TextureData textureData = AWTTextureIO.newTextureData(caps.getGLProfile(), textureImage, false); - glCanvas.addGLEventListener(new TextureGL2ListenerDraw1(textureData)); - - Animator animator = new Animator(glCanvas); - frame.setVisible(true); - animator.start(); - - try { - Thread.sleep(100); // 100 ms - } catch (Exception e) {} - - animator.stop(); - frame.setVisible(false); - - frame.remove(glCanvas); - frame.dispose(); - frame=null; - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(Texture1.class.getName()); - } -} diff --git a/src/jogl/junit/com/jogamp/opengl/test/junit/texture/util/gl2/TextureGL2ListenerDraw1.java b/src/jogl/junit/com/jogamp/opengl/test/junit/texture/util/gl2/TextureGL2ListenerDraw1.java deleted file mode 100755 index bdb8bd95a..000000000 --- a/src/jogl/junit/com/jogamp/opengl/test/junit/texture/util/gl2/TextureGL2ListenerDraw1.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2010 Sven Gothel. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution 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. - * - * Neither the name Sven Gothel or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -package com.jogamp.opengl.test.junit.texture.util.gl2; - -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureCoords; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GL2; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.glu.GLU; - -public class TextureGL2ListenerDraw1 implements GLEventListener { - private GLU glu = new GLU(); - private TextureData textureData; - private Texture texture; - - public TextureGL2ListenerDraw1(TextureData td) { - this.textureData = td; - } - - public void init(GLAutoDrawable drawable) { - this.texture = TextureIO.newTexture(textureData); - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - GL2 gl = drawable.getGL().getGL2(); - gl.glMatrixMode(GL2ES1.GL_PROJECTION); - gl.glLoadIdentity(); - glu.gluOrtho2D(0, 1, 0, 1); - gl.glMatrixMode(GL2ES1.GL_MODELVIEW); - gl.glLoadIdentity(); - } - - public void dispose(GLAutoDrawable drawable) { - GL2 gl = drawable.getGL().getGL2(); - if(null!=texture) { - texture.disable(); - texture.destroy(gl); - } - if(null!=textureData) { - textureData.destroy(); - } - } - - public void display(GLAutoDrawable drawable) { - GL2 gl = drawable.getGL().getGL2(); - - // need a valid GL context for this .. - - /** OpenGL .. - texture.updateSubImage(textureData, 0, - 20, 20, - 20, 20, - 100, 100); */ - - - // Now draw one quad with the texture - texture.enable(); - texture.bind(); - gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); - TextureCoords coords = texture.getImageTexCoords(); - gl.glBegin(GL2.GL_QUADS); - gl.glTexCoord2f(coords.left(), coords.bottom()); - gl.glVertex3f(0, 0, 0); - gl.glTexCoord2f(coords.right(), coords.bottom()); - gl.glVertex3f(1, 0, 0); - gl.glTexCoord2f(coords.right(), coords.top()); - gl.glVertex3f(1, 1, 0); - gl.glTexCoord2f(coords.left(), coords.top()); - gl.glVertex3f(0, 1, 0); - gl.glEnd(); - texture.disable(); - } -} - diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/texture/Texture1.java b/src/junit/com/jogamp/test/junit/jogl/awt/texture/Texture1.java new file mode 100755 index 000000000..6023bf87f --- /dev/null +++ b/src/junit/com/jogamp/test/junit/jogl/awt/texture/Texture1.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.test.junit.jogl.awt.texture; + +import com.jogamp.test.junit.jogl.util.texture.gl2.TextureGL2ListenerDraw1; + +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureCoords; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.util.texture.awt.AWTTextureIO; +import com.jogamp.opengl.util.Animator; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Frame; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class Texture1 { + Frame frame; + BufferedImage textureImage; + + @Before + public void init() { + // create base image + BufferedImage baseImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB); + Graphics2D g = baseImage.createGraphics(); + g.setPaint(new GradientPaint(0, 0, Color.CYAN, + baseImage.getWidth(), baseImage.getHeight(), Color.BLUE)); + g.fillRect(0, 0, baseImage.getWidth(), baseImage.getHeight()); + g.dispose(); + + // create texture image + int imageType = BufferedImage.TYPE_INT_RGB; + textureImage = new BufferedImage(baseImage.getWidth(), + baseImage.getHeight(), + imageType); + g = textureImage.createGraphics(); + g.setComposite(AlphaComposite.Src); + g.drawImage(baseImage, 0, 0, null); + g.dispose(); + + frame = new Frame("Texture Test"); + } + + @Test + public void test1() { + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3)); + GLCanvas glCanvas = new GLCanvas(caps); + frame.add(glCanvas); + frame.setSize(512, 512); + + // create texture + TextureData textureData = AWTTextureIO.newTextureData(caps.getGLProfile(), textureImage, false); + glCanvas.addGLEventListener(new TextureGL2ListenerDraw1(textureData)); + + Animator animator = new Animator(glCanvas); + frame.setVisible(true); + animator.start(); + + try { + Thread.sleep(100); // 100 ms + } catch (Exception e) {} + + animator.stop(); + frame.setVisible(false); + + frame.remove(glCanvas); + frame.dispose(); + frame=null; + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(Texture1.class.getName()); + } +} diff --git a/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java b/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java new file mode 100755 index 000000000..eabd4b79d --- /dev/null +++ b/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2010 Sven Gothel. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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. + * + * Neither the name Sven Gothel or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +package com.jogamp.test.junit.jogl.util.texture.gl2; + +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureCoords; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.glu.GLU; + +public class TextureGL2ListenerDraw1 implements GLEventListener { + private GLU glu = new GLU(); + private TextureData textureData; + private Texture texture; + + public TextureGL2ListenerDraw1(TextureData td) { + this.textureData = td; + } + + public void init(GLAutoDrawable drawable) { + this.texture = TextureIO.newTexture(textureData); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + GL2 gl = drawable.getGL().getGL2(); + gl.glMatrixMode(GL2ES1.GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluOrtho2D(0, 1, 0, 1); + gl.glMatrixMode(GL2ES1.GL_MODELVIEW); + gl.glLoadIdentity(); + } + + public void dispose(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); + if(null!=texture) { + texture.disable(); + texture.destroy(gl); + } + if(null!=textureData) { + textureData.destroy(); + } + } + + public void display(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); + + // need a valid GL context for this .. + + /** OpenGL .. + texture.updateSubImage(textureData, 0, + 20, 20, + 20, 20, + 100, 100); */ + + + // Now draw one quad with the texture + texture.enable(); + texture.bind(); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); + TextureCoords coords = texture.getImageTexCoords(); + gl.glBegin(GL2.GL_QUADS); + gl.glTexCoord2f(coords.left(), coords.bottom()); + gl.glVertex3f(0, 0, 0); + gl.glTexCoord2f(coords.right(), coords.bottom()); + gl.glVertex3f(1, 0, 0); + gl.glTexCoord2f(coords.right(), coords.top()); + gl.glVertex3f(1, 1, 0); + gl.glTexCoord2f(coords.left(), coords.top()); + gl.glVertex3f(0, 1, 0); + gl.glEnd(); + texture.disable(); + } +} + -- cgit v1.2.3