aboutsummaryrefslogtreecommitdiffstats
path: root/src/demo
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-01 06:48:52 +0200
committerSven Gothel <[email protected]>2011-04-01 06:48:52 +0200
commit4b8bd5ec58cb2edfb51bd9ee930beb9c539a8a0b (patch)
tree5567f56606ea248707fe002015b90a9635250e91 /src/demo
parente8c69e69374b6650e37594ebf104602fb06b548b (diff)
Final core and demo changes for jogl merge
Core: - Region: Cleanup up constant names - Renderer: Add getRenderType() - TextRenderer: Add cache size limit - JavaFontLoader: Add FIXME 'Add cache size to limit memory usage' - UbuntuFontLoader: Add cache and FIXME 'Add cache size to limit memory usage' - TypecastFont: Add FIXME 'Add cache size to limit memory usage ??' Demos: - Relocated and split (main/listener) for jogl merge - Add 's' for screenshot - Text: - Add 'i' for live editing mode (until CR, backspace supported)
Diffstat (limited to 'src/demo')
-rwxr-xr-xsrc/demo/GPURegionNewtDemo01.java179
-rw-r--r--src/demo/GPURegionNewtDemo02.java170
-rw-r--r--src/demo/GPURegionRendererListenerBase01.java52
-rw-r--r--src/demo/GPURendererListenerBase01.java231
-rw-r--r--src/demo/GPUTextNewtDemo01.java107
-rw-r--r--src/demo/GPUTextNewtDemo02.java115
-rw-r--r--src/demo/GPUTextRendererListenerBase01.java190
-rw-r--r--src/demo/MSAATool.java69
-rw-r--r--src/demo/ReadBufferUtil.java109
-rw-r--r--src/demo/Screenshot.java39
10 files changed, 0 insertions, 1261 deletions
diff --git a/src/demo/GPURegionNewtDemo01.java b/src/demo/GPURegionNewtDemo01.java
deleted file mode 100755
index 676621692..000000000
--- a/src/demo/GPURegionNewtDemo01.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.geom.opengl.SVertex;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.util.Animator;
-
-/** Demonstrate the rendering of multiple outlines into one region/OutlineShape
- * These Outlines are not necessary connected or contained.
- * The output of this demo shows two identical shapes but the left one
- * has some vertices with off-curve flag set to true, and the right allt he vertices
- * are on the curve. Demos the Res. Independent Nurbs based Curve rendering
- *
- */
-public class GPURegionNewtDemo01 {
- static final boolean DEBUG = false;
- static final boolean TRACE = false;
-
- public static void main(String[] args) {
- GPURegionNewtDemo01 test = new GPURegionNewtDemo01();
- test.testMe();
- }
-
- RegionGLListener regionGLListener = null;
- GLWindow window;
-
- public void testMe() {
- GLProfile.initSingleton(true);
- GLProfile glp = GLProfile.getGL2ES2();
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4); // 2 samples is not enough ..
- System.out.println("Requested: " + caps);
-
- GLWindow w = GLWindow.create(caps);
- w.setPosition(10, 10);
- w.setSize(800, 400);
- w.setTitle("GPU Curve Region Newt Demo 01 - r2t0 msaa1");
-
- regionGLListener = createRegionRendererListener(w);
-
- window.addGLEventListener(regionGLListener);
-
- window.enablePerfLog(true);
- window.setVisible(true);
-
- //FPSAnimator animator = new FPSAnimator(60);
- Animator animator = new Animator();
- animator.add(window);
- animator.start();
- }
-
- public RegionGLListener createRegionRendererListener(GLWindow w) {
- this.window = w;
-
- RegionGLListener l = new RegionGLListener();
- l.attachInputListenerTo(w);
-
- return l;
- }
-
- public class RegionGLListener extends GPURegionRendererListenerBase01 {
- OutlineShape outlineShape = null;
-
- public RegionGLListener() {
- super(SVertex.factory(), Region.SINGLE_PASS, DEBUG, TRACE);
- setMatrix(-20, 00, 0f, -50, 400);
- }
-
- private void createTestOutline(){
- float offset = 0;
- outlineShape = new OutlineShape(getRenderer().getFactory());
- outlineShape.addVertex(0.0f,-10.0f, true);
- outlineShape.addVertex(15.0f,-10.0f, true);
- outlineShape.addVertex(10.0f,5.0f, false);
- outlineShape.addVertex(15.0f,10.0f, true);
- outlineShape.addVertex(6.0f,15.0f, false);
- outlineShape.addVertex(5.0f,8.0f, false);
- outlineShape.addVertex(0.0f,10.0f,true);
- outlineShape.closeLastOutline();
- outlineShape.addEmptyOutline();
- outlineShape.addVertex(5.0f,-5.0f,true);
- outlineShape.addVertex(10.0f,-5.0f, false);
- outlineShape.addVertex(10.0f,0.0f, true);
- outlineShape.addVertex(5.0f,0.0f, false);
- outlineShape.closeLastOutline();
-
- /** Same shape as above but without any off-curve vertices */
- outlineShape.addEmptyOutline();
- offset = 30;
- outlineShape.addVertex(offset+0.0f,-10.0f, true);
- outlineShape.addVertex(offset+17.0f,-10.0f, true);
- outlineShape.addVertex(offset+11.0f,5.0f, true);
- outlineShape.addVertex(offset+16.0f,10.0f, true);
- outlineShape.addVertex(offset+7.0f,15.0f, true);
- outlineShape.addVertex(offset+6.0f,8.0f, true);
- outlineShape.addVertex(offset+0.0f,10.0f, true);
- outlineShape.closeLastOutline();
- outlineShape.addEmptyOutline();
- outlineShape.addVertex(offset+5.0f,0.0f, true);
- outlineShape.addVertex(offset+5.0f,-5.0f, true);
- outlineShape.addVertex(offset+10.0f,-5.0f, true);
- outlineShape.addVertex(offset+10.0f,0.0f, true);
- outlineShape.closeLastOutline();
- }
-
- public void init(GLAutoDrawable drawable) {
- super.init(drawable);
-
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
-
- gl.setSwapInterval(1);
- gl.glEnable(GL2ES2.GL_DEPTH_TEST);
- regionRenderer.init(gl);
- regionRenderer.setAlpha(gl, 1.0f);
- regionRenderer.setColor(gl, 0.0f, 0.0f, 0.0f);
- //gl.glSampleCoverage(0.95f, false);
- //gl.glEnable(GL2GL3.GL_SAMPLE_COVERAGE); // sample coverage doesn't really make a difference to lines
- //gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE);
- MSAATool.dump(drawable);
-
- createTestOutline();
- }
-
- public void display(GLAutoDrawable drawable) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
-
- regionRenderer.resetModelview(null);
- regionRenderer.translate(null, getXTran(), getYTran(), getZoom());
- regionRenderer.rotate(gl, getAngle(), 0, 1, 0);
-
- regionRenderer.renderOutlineShape(gl, outlineShape, getPosition(), getTexSize());
- }
- }
-}
diff --git a/src/demo/GPURegionNewtDemo02.java b/src/demo/GPURegionNewtDemo02.java
deleted file mode 100644
index 3d7b60574..000000000
--- a/src/demo/GPURegionNewtDemo02.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.geom.opengl.SVertex;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.util.Animator;
-
-/** Demonstrate the rendering of multiple OutlineShapes
- * into one region
- *
- */
-public class GPURegionNewtDemo02 {
- static final boolean DEBUG = false;
- static final boolean TRACE = false;
-
- public static void main(String[] args) {
- GPURegionNewtDemo02 test = new GPURegionNewtDemo02();
- test.testMe();
- }
-
- RegionGLListener regionGLListener = null;
- GLWindow window;
- public void testMe() {
- GLProfile.initSingleton(true);
- GLProfile glp = GLProfile.get(GLProfile.GL3);
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- System.out.println("Requested: " + caps);
-
- GLWindow w = GLWindow.create(caps);
- w.setPosition(10, 10);
- w.setSize(800, 400);
- w.setTitle("GPU Curve Region Newt Demo 02 - r2t1 msaa0");
-
- regionGLListener = createRegionRendererListener(w);
- window.addGLEventListener(regionGLListener);
-
- window.enablePerfLog(true);
- window.setVisible(true);
-
- //FPSAnimator animator = new FPSAnimator(60);
- Animator animator = new Animator();
- animator.add(window);
- animator.start();
- }
-
- public RegionGLListener createRegionRendererListener(GLWindow w) {
- this.window = w;
-
- RegionGLListener l = new RegionGLListener();
- l.attachInputListenerTo(w);
-
- return l;
- }
-
- public class RegionGLListener extends GPURegionRendererListenerBase01 {
- OutlineShape[] outlineShapes = new OutlineShape[2];
-
- public RegionGLListener() {
- super(SVertex.factory(), Region.TWO_PASS, DEBUG, TRACE);
- setMatrix(-20, 00, 0f, -50, 1140);
- }
-
- private void createTestOutline(){
- float offset = 0;
- outlineShapes[0] = new OutlineShape(SVertex.factory());
- outlineShapes[0].addVertex(0.0f,-10.0f,true);
- outlineShapes[0].addVertex(15.0f,-10.0f, true);
- outlineShapes[0].addVertex(10.0f,5.0f, false);
- outlineShapes[0].addVertex(15.0f,10.0f, true);
- outlineShapes[0].addVertex(6.0f,15.0f, false);
- outlineShapes[0].addVertex(5.0f,8.0f, false);
- outlineShapes[0].addVertex(0.0f,10.0f,true);
- outlineShapes[0].closeLastOutline();
- outlineShapes[0].addEmptyOutline();
- outlineShapes[0].addVertex(5.0f,-5.0f,true);
- outlineShapes[0].addVertex(10.0f,-5.0f, false);
- outlineShapes[0].addVertex(10.0f,0.0f, true);
- outlineShapes[0].addVertex(5.0f,0.0f, false);
- outlineShapes[0].closeLastOutline();
-
- /** Same shape as above but without any off-curve vertices */
- outlineShapes[1] = new OutlineShape(SVertex.factory());
- offset = 30;
- outlineShapes[1].addVertex(offset+0.0f,-10.0f, true);
- outlineShapes[1].addVertex(offset+17.0f,-10.0f, true);
- outlineShapes[1].addVertex(offset+11.0f,5.0f, true);
- outlineShapes[1].addVertex(offset+16.0f,10.0f, true);
- outlineShapes[1].addVertex(offset+7.0f,15.0f, true);
- outlineShapes[1].addVertex(offset+6.0f,8.0f, true);
- outlineShapes[1].addVertex(offset+0.0f,10.0f, true);
- outlineShapes[1].closeLastOutline();
- outlineShapes[1].addEmptyOutline();
- outlineShapes[1].addVertex(offset+5.0f,0.0f, true);
- outlineShapes[1].addVertex(offset+5.0f,-5.0f, true);
- outlineShapes[1].addVertex(offset+10.0f,-5.0f, true);
- outlineShapes[1].addVertex(offset+10.0f,0.0f, true);
- outlineShapes[1].closeLastOutline();
- }
-
- public void init(GLAutoDrawable drawable) {
- super.init(drawable);
-
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
-
- gl.setSwapInterval(1);
- gl.glEnable(GL2ES2.GL_DEPTH_TEST);
- regionRenderer.init(gl);
- regionRenderer.setAlpha(gl, 1.0f);
- regionRenderer.setColor(gl, 0.0f, 0.0f, 0.0f);
- MSAATool.dump(drawable);
-
- createTestOutline();
- }
-
- public void display(GLAutoDrawable drawable) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
-
- regionRenderer.resetModelview(null);
- regionRenderer.translate(null, getXTran(), getYTran(), getZoom());
- regionRenderer.rotate(gl, getAngle(), 0, 1, 0);
-
- regionRenderer.renderOutlineShapes(gl, outlineShapes, getPosition(), getTexSize());
-
- }
- }
-}
diff --git a/src/demo/GPURegionRendererListenerBase01.java b/src/demo/GPURegionRendererListenerBase01.java
deleted file mode 100644
index 39a920656..000000000
--- a/src/demo/GPURegionRendererListenerBase01.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.geom.Vertex;
-
-/**
- *
- * Action Keys:
- * - 1/2: zoom in/out
- * - 3/4: font +/-
- * - 6/7: 2nd pass texture size
- * - 0/9: rotate
- * - s: toogle draw 'font set'
- * - f: toggle draw fps
- * - v: toggle v-sync
- * - space: toggle font (ubuntu/java)
- */
-public abstract class GPURegionRendererListenerBase01 extends GPURendererListenerBase01 {
- OutlineShape outlineShape = null;
-
- public GPURegionRendererListenerBase01(Vertex.Factory<? extends Vertex> factory, int mode, boolean debug, boolean trace) {
- super(RegionRenderer.create(factory, mode), debug, trace);
- }
-} \ No newline at end of file
diff --git a/src/demo/GPURendererListenerBase01.java b/src/demo/GPURendererListenerBase01.java
deleted file mode 100644
index e8dec4c01..000000000
--- a/src/demo/GPURendererListenerBase01.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLAnimatorControl;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLPipelineFactory;
-import javax.media.opengl.GLRunnable;
-
-import com.jogamp.graph.curve.opengl.Renderer;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.KeyListener;
-import com.jogamp.newt.opengl.GLWindow;
-
-/**
- *
- * Action Keys:
- * - 1/2: zoom in/out
- * - 6/7: 2nd pass texture size
- * - 0/9: rotate
- * - v: toggle v-sync
- */
-public abstract class GPURendererListenerBase01 implements GLEventListener {
- private Screenshot screenshot;
- private Renderer renderer;
- private boolean debug;
- private boolean trace;
-
- private KeyAction keyAction;
-
- private volatile GLAutoDrawable autoDrawable = null;
-
- private final float[] position = new float[] {0,0,0};
-
- private float xTran = -10;
- private float yTran = 10;
- private float ang = 0f;
- private float zoom = -70f;
- private int texSize = 400;
-
- boolean updateMatrix = true;
-
- public GPURendererListenerBase01(Renderer renderer, boolean debug, boolean trace) {
- this.renderer = renderer;
- this.debug = debug;
- this.trace = trace;
- this.screenshot = new Screenshot();
- }
-
- public final Renderer getRenderer() { return renderer; }
- public final float getZoom() { return zoom; }
- public final float getXTran() { return xTran; }
- public final float getYTran() { return yTran; }
- public final float getAngle() { return ang; }
- public final int getTexSize() { return texSize; }
- public final float[] getPosition() { return position; }
-
- public void setMatrix(float xtrans, float ytrans, float angle, int zoom, int fbosize) {
- this.xTran = xtrans;
- this.yTran = ytrans;
- this.ang = angle;
- this.zoom = zoom;
- this.texSize = fbosize;
- updateMatrix = true;
- }
-
- public void init(GLAutoDrawable drawable) {
- autoDrawable = drawable;
- GL2ES2 gl = drawable.getGL().getGL2ES2();
- if(debug) {
- gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ).getGL2ES2();
- }
- if(trace) {
- gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2();
- }
- gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- }
-
- public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- gl.glViewport(xstart, ystart, width, height);
- renderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 7000.0f);
-
- dumpMatrix();
- }
-
- public void dispose(GLAutoDrawable drawable) {
- autoDrawable = null;
- GL2ES2 gl = drawable.getGL().getGL2ES2();
- screenshot.dispose();
- renderer.dispose(gl);
- }
-
- public void zoom(int v){
- zoom += v;
- updateMatrix = true;
- dumpMatrix();
- }
-
- public void move(float x, float y){
- xTran += x;
- yTran += y;
- updateMatrix = true;
- dumpMatrix();
- }
- public void rotate(float delta){
- ang += delta;
- ang %= 360.0f;
- updateMatrix = true;
- dumpMatrix();
- }
-
- void dumpMatrix() {
- System.err.println("Matrix: " + xTran + "/" + yTran + " x"+zoom + " @"+ang);
- }
-
- /** Attach the input listener to the window */
- public void attachInputListenerTo(GLWindow window) {
- if ( null == keyAction ) {
- keyAction = new KeyAction();
- window.addKeyListener(keyAction);
- }
- }
-
- public void detachFrom(GLWindow window) {
- if ( null == keyAction ) {
- return;
- }
- window.removeGLEventListener(this);
- window.removeKeyListener(keyAction);
- }
-
- public void printScreen(GLAutoDrawable drawable, String dir, String tech, String objName, boolean exportAlpha) throws GLException, IOException {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize, objName);
-
- String filename = dir + tech + sw +".tga";
- screenshot.surface2File(drawable, filename /*, exportAlpha */);
- }
-
- public class KeyAction implements KeyListener {
- public void keyPressed(KeyEvent arg0) {
- if(arg0.getKeyCode() == KeyEvent.VK_1){
- zoom(10);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_2){
- zoom(-10);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_UP){
- move(0, -1);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){
- move(0, 1);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_LEFT){
- move(1, 0);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){
- move(-1, 0);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_6){
- texSize -= 10;
- System.err.println("Tex Size: " + texSize);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_7){
- texSize += 10;
- System.err.println("Tex Size: " + texSize);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_0){
- rotate(1);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_9){
- rotate(-1);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_V) {
- if(null != autoDrawable) {
- autoDrawable.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- int i = gl.getSwapInterval();
- i = i==0 ? 1 : 0;
- gl.setSwapInterval(i);
- final GLAnimatorControl a = drawable.getAnimator();
- if( null != a ) {
- a.resetCounter();
- }
- System.err.println("Swap Interval: "+i);
- }
- });
- }
- }
- }
- public void keyTyped(KeyEvent arg0) {}
- public void keyReleased(KeyEvent arg0) {}
- }
-}
diff --git a/src/demo/GPUTextNewtDemo01.java b/src/demo/GPUTextNewtDemo01.java
deleted file mode 100644
index 9a3067548..000000000
--- a/src/demo/GPUTextNewtDemo01.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.TextRenderer;
-import com.jogamp.graph.geom.opengl.SVertex;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.util.Animator;
-
-public class GPUTextNewtDemo01 {
- static final boolean DEBUG = false;
- static final boolean TRACE = false;
-
- public static void main(String[] args) {
- GPUTextNewtDemo01 test = new GPUTextNewtDemo01();
- test.testMe();
- }
-
- TextGLListener textGLListener = null;
- GLWindow window;
- public void testMe() {
- GLProfile.initSingleton(true);
- GLProfile glp = GLProfile.getGL2ES2();
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4); // 2 samples is not enough ..
- System.out.println("Requested: "+caps);
-
- window = GLWindow.create(caps);
- window.setPosition(10, 10);
- window.setSize(800, 400);
- window.setTitle("GPU Text Newt Demo 01 - r2t0 msaa1");
-
- textGLListener = new TextGLListener();
- textGLListener.attachInputListenerTo(window);
- window.addGLEventListener(textGLListener);
-
- window.enablePerfLog(true);
- window.setVisible(true);
- // FPSAnimator animator = new FPSAnimator(10);
- Animator animator = new Animator();
- animator.add(window);
- animator.start();
- }
-
- private class TextGLListener extends GPUTextRendererListenerBase01 {
- public TextGLListener() {
- super(SVertex.factory(), Region.SINGLE_PASS, DEBUG, TRACE);
- // FBO size unrelated with 1 pass
- //setMatrix(-10, 10, 0f, -70, 0);
- // setMatrix(-80, -30, 0f, -100, 0);
- setMatrix(-400, -30, 0f, -500, 0);
- }
-
- public void init(GLAutoDrawable drawable) {
- super.init(drawable);
-
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- final TextRenderer textRenderer = (TextRenderer) getRenderer();
-
- gl.setSwapInterval(1);
- gl.glEnable(GL2ES2.GL_DEPTH_TEST);
- textRenderer.init(gl);
- textRenderer.setAlpha(gl, 1.0f);
- textRenderer.setColor(gl, 0.0f, 0.0f, 0.0f);
- //gl.glSampleCoverage(0.95f, false);
- //gl.glEnable(GL2GL3.GL_SAMPLE_COVERAGE); // sample coverage doesn't really make a difference to lines
- //gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_COVERAGE);
- //gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE);
- MSAATool.dump(drawable);
- }
- }
-}
diff --git a/src/demo/GPUTextNewtDemo02.java b/src/demo/GPUTextNewtDemo02.java
deleted file mode 100644
index 2078527dc..000000000
--- a/src/demo/GPUTextNewtDemo02.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL3;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.TextRenderer;
-import com.jogamp.graph.geom.opengl.SVertex;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.util.Animator;
-
-public class GPUTextNewtDemo02 {
- /**
- * If DEBUG is enabled:
- *
- * Caused by: javax.media.opengl.GLException: Thread[main-Display-X11_:0.0-1-EDT-1,5,main] glGetError() returned the following error codes after a call to glFramebufferRenderbuffer(<int> 0x8D40, <int> 0x1902, <int> 0x8D41, <int> 0x1): GL_INVALID_ENUM ( 1280 0x500),
- * at javax.media.opengl.DebugGL4bc.checkGLGetError(DebugGL4bc.java:33961)
- * at javax.media.opengl.DebugGL4bc.glFramebufferRenderbuffer(DebugGL4bc.java:33077)
- * at jogamp.graph.curve.opengl.VBORegion2PGL3.initFBOTexture(VBORegion2PGL3.java:295)
- */
- static final boolean DEBUG = false;
- static final boolean TRACE = false;
-
- public static void main(String[] args) {
- GPUTextNewtDemo02 test = new GPUTextNewtDemo02();
- test.testMe();
- }
-
- GLWindow window;
- TextGLListener textGLListener = null;
-
- public void testMe() {
- GLProfile.initSingleton(true);
- GLProfile glp = GLProfile.get(GLProfile.GL3);
-
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- System.out.println("Requested: "+caps);
-
- window = GLWindow.create(caps);
-
- window.setPosition(10, 10);
- window.setSize(800, 400);
-
- window.setTitle("GPU Text Newt Demo 02 - r2t1 msaa0");
- textGLListener = new TextGLListener();
- textGLListener.attachInputListenerTo(window);
- window.addGLEventListener(textGLListener);
-
- window.enablePerfLog(true);
- window.setVisible(true);
-
- // FPSAnimator animator = new FPSAnimator(60);
- Animator animator = new Animator();
- animator.add(window);
- animator.start();
- }
-
- private class TextGLListener extends GPUTextRendererListenerBase01 {
- public TextGLListener() {
- super(SVertex.factory(), Region.TWO_PASS, DEBUG, TRACE);
- // FIXME: Rami will fix FBO size !!
- // setMatrix(-10, 10, 0f, -100, 400);
- // setMatrix(-80, -30, 0f, -100, window.getWidth()*3);
- setMatrix(-400, -30, 0f, -500, window.getWidth()*3);
- }
-
- public void init(GLAutoDrawable drawable) {
- super.init(drawable);
-
- GL3 gl = drawable.getGL().getGL3();
-
- final TextRenderer textRenderer = (TextRenderer) getRenderer();
-
- gl.setSwapInterval(1);
- gl.glEnable(GL3.GL_DEPTH_TEST);
- textRenderer.init(gl);
- textRenderer.setAlpha(gl, 1.0f);
- textRenderer.setColor(gl, 0.0f, 0.0f, 0.0f);
- gl.glDisable(GL.GL_MULTISAMPLE); // this state usually doesn't matter in driver - but document here: no MSAA
- //gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL3.GL_NICEST);
- MSAATool.dump(drawable);
- }
- }
-}
diff --git a/src/demo/GPUTextRendererListenerBase01.java b/src/demo/GPUTextRendererListenerBase01.java
deleted file mode 100644
index d3f46ca20..000000000
--- a/src/demo/GPUTextRendererListenerBase01.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import java.io.IOException;
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLAnimatorControl;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLException;
-import com.jogamp.graph.curve.opengl.TextRenderer;
-import com.jogamp.graph.font.Font;
-import com.jogamp.graph.font.FontFactory;
-import com.jogamp.graph.geom.Vertex;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.KeyListener;
-import com.jogamp.newt.opengl.GLWindow;
-
-/**
- *
- * GPURendererListenerBase01 Keys:
- * - 1/2: zoom in/out
- * - 6/7: 2nd pass texture size
- * - 0/9: rotate
- * - v: toggle v-sync
- *
- * Additional Keys:
- * - 3/4: font +/-
- * - s: toogle draw 'font set'
- * - f: toggle draw fps
- * - space: toggle font (ubuntu/java)
- */
-public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerBase01 {
- int fontSet = FontFactory.UBUNTU;
- Font font;
-
- boolean drawFontSet = true;
- boolean drawFPS = true;
- boolean updateFont = true;
- int fontSize = 40;
- final int fontSizeModulo = 100;
-
- static final String text1 = "abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n0123456789.:,;(*!?/\\\")$%^&-+@~#<>{}[]";
- static final String text2 = "The quick brown fox jumps over the lazy dog";
-
- public GPUTextRendererListenerBase01(Vertex.Factory<? extends Vertex> factory, int mode, boolean debug, boolean trace) {
- super(TextRenderer.create(factory, mode), debug, trace);
- this.font = FontFactory.get(fontSet).getDefault();
- }
-
- public void display(GLAutoDrawable drawable) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Demo02 needs to have this set here as well .. hmm ?
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- final TextRenderer textRenderer = (TextRenderer) getRenderer();
-
- if(drawFPS || drawFontSet || updateMatrix) {
- final int width = drawable.getWidth();
- final int height = drawable.getHeight();
- final GLAnimatorControl animator = drawable.getAnimator();
- final boolean _drawFPS = drawFPS && null != animator && animator.getTotalFrames()>10;
-
- if(_drawFPS || drawFontSet) {
- textRenderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f);
- }
- if(_drawFPS) {
- final float fps = ( animator.getTotalFrames() * 1000.0f ) / (float) animator.getDuration() ;
- final String fpsS = String.valueOf(fps);
- final int fpsSp = fpsS.indexOf('.');
- textRenderer.resetModelview(null);
- textRenderer.translate(gl, 0, 0, -6000);
- textRenderer.renderString3D(gl, font, fpsS.substring(0, fpsSp+2), getPosition(), fontSize, getTexSize());
- }
- if(drawFontSet) {
- textRenderer.resetModelview(null);
- textRenderer.translate(gl, 0, height-50, -6000);
- textRenderer.renderString3D(gl, font, text1, getPosition(), fontSize, getTexSize());
- }
- if(_drawFPS || drawFontSet) {
- textRenderer.reshapePerspective(null, 45.0f, width, height, 0.1f, 7000.0f);
- }
-
- textRenderer.resetModelview(null);
- textRenderer.translate(null, getXTran(), getYTran(), getZoom());
- textRenderer.rotate(gl, getAngle(), 0, 1, 0);
- updateMatrix = false;
- }
-
- textRenderer.renderString3D(gl, font, text2, getPosition(), fontSize, getTexSize());
- }
-
- public void fontIncr(int v) {
- fontSize = Math.abs((fontSize + v) % fontSizeModulo) ;
- updateFont = true;
- dumpMatrix(true);
- }
-
- public void nextFontSet() {
- fontSet = ( fontSet == FontFactory.UBUNTU ) ? FontFactory.JAVA : FontFactory.UBUNTU ;
- font = FontFactory.get(fontSet).getDefault();
- }
-
- public void setFontSet(int set, int family, int stylebits) {
- fontSet = set;
- font = FontFactory.get(fontSet).get(family, stylebits);
- }
-
- void dumpMatrix(boolean bbox) {
- System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZoom() + " @"+getAngle() +" fontSize "+fontSize);
- if(bbox) {
- System.err.println("bbox: "+font.getStringBounds(text2, fontSize));
- }
- }
-
- KeyAction keyAction = null;
-
- @Override
- public void attachInputListenerTo(GLWindow window) {
- if ( null == keyAction ) {
- keyAction = new KeyAction();
- window.addKeyListener(keyAction);
- super.attachInputListenerTo(window);
- }
-
- }
-
- @Override
- public void detachFrom(GLWindow window) {
- super.detachFrom(window);
- if ( null == keyAction ) {
- return;
- }
- window.removeKeyListener(keyAction);
- }
-
- public void printScreen(GLAutoDrawable drawable, String dir, String tech, boolean exportAlpha) throws GLException, IOException {
- printScreen(drawable, dir, tech, font.getName(), exportAlpha);
- }
-
- public class KeyAction implements KeyListener {
- public void keyPressed(KeyEvent arg0) {
- if(arg0.getKeyCode() == KeyEvent.VK_3){
- fontIncr(10);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_4){
- fontIncr(-10);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_S) {
- drawFontSet = !drawFontSet;
- System.err.println("Draw font set: "+drawFontSet);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_F){
- drawFPS = !drawFPS;
- System.err.println("Draw FPS: "+drawFPS);
- }
- else if(arg0.getKeyCode() == KeyEvent.VK_SPACE) {
- nextFontSet();
- }
- }
- public void keyTyped(KeyEvent arg0) {}
- public void keyReleased(KeyEvent arg0) {}
- }
-} \ No newline at end of file
diff --git a/src/demo/MSAATool.java b/src/demo/MSAATool.java
deleted file mode 100644
index e357a3239..000000000
--- a/src/demo/MSAATool.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GL2GL3;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilitiesImmutable;
-
-public class MSAATool {
- public static void dump(GLAutoDrawable drawable) {
- float[] vf = new float[] { 0f };
- byte[] vb = new byte[] { 0 };
- int[] vi = new int[] { 0, 0 };
-
- System.out.println("GL MSAA SETUP:");
- GL2ES2 gl = drawable.getGL().getGL2ES2();
- GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities();
- System.out.println(" Caps realised "+caps);
- System.out.println(" Caps sample buffers "+caps.getSampleBuffers()+", samples "+caps.getNumSamples());
-
- // default TRUE
- System.out.println(" GL MULTISAMPLE "+gl.glIsEnabled(GL2ES2.GL_MULTISAMPLE));
- // sample buffers min 0, same as GLX_SAMPLE_BUFFERS_ARB or WGL_SAMPLE_BUFFERS_ARB
- gl.glGetIntegerv(GL2GL3.GL_SAMPLE_BUFFERS, vi, 0);
- // samples min 0
- gl.glGetIntegerv(GL2GL3.GL_SAMPLES, vi, 1);
- System.out.println(" GL SAMPLE_BUFFERS "+vi[0]+", SAMPLES "+vi[1]);
-
- System.out.println("GL CSAA SETUP:");
- // default FALSE
- System.out.println(" GL SAMPLE COVERAGE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_COVERAGE));
- // default FALSE
- System.out.println(" GL SAMPLE_ALPHA_TO_COVERAGE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_ALPHA_TO_COVERAGE));
- // default FALSE
- System.out.println(" GL SAMPLE_ALPHA_TO_ONE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE));
- // default FALSE, value 1, invert false
- gl.glGetFloatv(GL2GL3.GL_SAMPLE_COVERAGE_VALUE, vf, 0);
- gl.glGetBooleanv(GL2GL3.GL_SAMPLE_COVERAGE_INVERT, vb, 0);
- System.out.println(" GL SAMPLE_COVERAGE "+gl.glIsEnabled(GL2GL3.GL_SAMPLE_COVERAGE) +
- ": SAMPLE_COVERAGE_VALUE "+vf[0]+
- ", SAMPLE_COVERAGE_INVERT "+vb[0]);
- }
-}
diff --git a/src/demo/ReadBufferUtil.java b/src/demo/ReadBufferUtil.java
deleted file mode 100644
index 9a2da0d7e..000000000
--- a/src/demo/ReadBufferUtil.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Copyright 2010 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 demo;
-
-import com.jogamp.opengl.util.GLBuffers;
-import java.nio.*;
-import javax.media.opengl.*;
-
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureData;
-
-public class ReadBufferUtil {
- protected int readPixelSizeLast = 0;
- protected Buffer readPixelBuffer = null;
- protected TextureData readTextureData = null;
- protected Texture readTexture = new Texture(GL.GL_TEXTURE_2D);
-
- public Buffer getPixelBuffer() { return readPixelBuffer; }
- public void rewindPixelBuffer() { readPixelBuffer.rewind(); }
-
- public TextureData getTextureData() { return readTextureData; }
- public Texture getTexture() { return readTexture; }
-
- public boolean isValid() {
- return null!=readTexture && null!=readTextureData && null!=readPixelBuffer ;
- }
-
- public void fetchOffscreenTexture(GLDrawable drawable, GL gl) {
- int readPixelSize = drawable.getWidth() * drawable.getHeight() * 3 ; // RGB
- boolean newData = false;
- if(readPixelSize>readPixelSizeLast) {
- readPixelBuffer = GLBuffers.newDirectGLBuffer(GL.GL_UNSIGNED_BYTE, readPixelSize);
- readPixelSizeLast = readPixelSize ;
- try {
- readTextureData = new TextureData(
- gl.getGLProfile(),
- // gl.isGL2GL3()?gl.GL_RGBA:gl.GL_RGB,
- GL.GL_RGB,
- drawable.getWidth(), drawable.getHeight(),
- 0,
- GL.GL_RGB,
- GL.GL_UNSIGNED_BYTE,
- false, false,
- false /* flip */,
- readPixelBuffer,
- null /* Flusher */);
- newData = true;
- } catch (Exception e) {
- readTextureData = null;
- readPixelBuffer = null;
- readPixelSizeLast = 0;
- throw new RuntimeException("can not fetch offscreen texture", e);
- }
- }
- if(null!=readPixelBuffer) {
- readPixelBuffer.clear();
- gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer);
- readPixelBuffer.rewind();
- if(newData) {
- readTexture.updateImage(readTextureData);
- } else {
- readTexture.updateSubImage(readTextureData, 0,
- 0, 0, // src offset
- 0, 0, // dst offset
- drawable.getWidth(), drawable.getHeight());
- }
- readPixelBuffer.rewind();
- }
- }
-
- @SuppressWarnings("deprecation")
- public void dispose() {
- readTexture.dispose();
- readTextureData = null;
- if(null != readPixelBuffer) {
- readPixelBuffer.clear();
- readPixelBuffer = null;
- }
- readPixelSizeLast = 0;
- }
-
-}
-
diff --git a/src/demo/Screenshot.java b/src/demo/Screenshot.java
deleted file mode 100644
index 8e05b17ea..000000000
--- a/src/demo/Screenshot.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package demo;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
-
-import com.jogamp.opengl.util.texture.TextureIO;
-
-public class Screenshot {
-
- ReadBufferUtil readBufferUtil = new ReadBufferUtil();
-
- public void dispose() {
- readBufferUtil.dispose();
- }
-
- public void surface2File(GLAutoDrawable drawable, String filename) {
- GL gl = drawable.getGL();
- // FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec
- gl.glFinish();
- readBufferUtil.fetchOffscreenTexture(drawable, gl);
- gl.glFinish();
- try {
- surface2File(filename);
- } catch (IOException ex) {
- throw new RuntimeException("can not write survace to file", ex);
- }
- }
-
- void surface2File(String filename) throws IOException {
- File file = new File(filename);
- TextureIO.write(readBufferUtil.getTextureData(), file);
- System.err.println("Wrote: " + file.getAbsolutePath() + ", ...");
- readBufferUtil.rewindPixelBuffer();
- }
-
-}