diff options
author | Rami Santina <[email protected]> | 2011-04-08 17:46:05 +0300 |
---|---|---|
committer | Rami Santina <[email protected]> | 2011-04-08 17:46:05 +0300 |
commit | e6de1dcd253ef4d6ba9f584b4ed3540c85c66d2c (patch) | |
tree | 94c71637205769a4ad58faea7496e5da463c5a37 /src/test | |
parent | deca38fce30548d0ee624b7c747daacafca37f24 (diff) |
Added demo GPU Resolution Indep UI - Button;
RIButton - resolution independent vector based button
UINewtDemo01 --> shows a testcase of a button rendered on scene.
controls: 1/2: zoom in/out
4/5: increase/decrease shape/text spacing
6/7: increase/decrease corner size
0/9: rotate.
Diffstat (limited to 'src/test')
5 files changed, 730 insertions, 0 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java new file mode 100644 index 000000000..c801a2499 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java @@ -0,0 +1,175 @@ +package com.jogamp.opengl.test.junit.graph.demos.ui; + +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.geom.AABBox; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; + +public class RIButton extends UIControl{ + private float width = 4.0f, height= 3.0f; + private float spacing = 0.3f; + private float[] scale = new float[]{1.0f,1.0f}; + private float corner = 0.5f; + private float labelZOffset = -0.05f; + + private float[] buttonColor = {0.0f, 0.0f, 0.0f}; + private float[] labelColor = {1.0f, 1.0f, 1.0f}; + + public RIButton(Factory<? extends Vertex> factory, String label){ + super(factory); + this.label = label; + setFont(FontFactory.get(FontFactory.UBUNTU).getDefault()); + } + + public RIButton(Factory<? extends Vertex> factory, String label, Font font){ + super(factory); + setLabel(label); + setFont(font); + } + + public float getWidth() { + return width; + } + + public void setDimensions(float width, float height) { + this.width = width; + this.height = height; + setDirty(true); + } + + public float getHeight() { + return height; + } + + public Font getFont() { + return font; + } + + public void generate(AABBox lbox) { +// AABBox lbox = font.getStringBounds(label, 10); + createOutline(factory, lbox); + scale[0] = getWidth()/(2*spacing + lbox.getWidth()); + scale[1] = getHeight()/(2*spacing + lbox.getHeight()); + + //FIXME: generate GlyphString to manipulate before rendering + setDirty(false); + } + + + public float[] getScale() { + return scale; + } + + private void createOutline(Factory<? extends Vertex> factory, AABBox lbox){ + shape = new OutlineShape(factory); + if(corner == 0.0f){ + createSharpOutline(lbox); + } + else{ + createCurvedOutline(lbox); + } + } + private void createSharpOutline(AABBox lbox){ + float th = (2.0f*spacing) + lbox.getHeight(); + float tw = (2.0f*spacing) + lbox.getWidth(); + float minX = lbox.getMinX()-spacing; + float minY = lbox.getMinY()-spacing; + + shape.addVertex(minX, minY, labelZOffset, true); + shape.addVertex(minX+tw, minY, labelZOffset, true); + shape.addVertex(minX+tw, minY + th, labelZOffset, true); + shape.addVertex(minX, minY + th, labelZOffset, true); + shape.closeLastOutline(); + } + + private void createCurvedOutline(AABBox lbox){ + float th = 2.0f*spacing + lbox.getHeight(); + float tw = 2.0f*spacing + lbox.getWidth(); + + float cw = 0.5f*corner*Math.min(tw, th); + float ch = 0.5f*corner*Math.min(tw, th); + + float minX = lbox.getMinX()-spacing; + float minY = lbox.getMinY()-spacing; + + shape.addVertex(minX, minY + ch, labelZOffset, true); + shape.addVertex(minX, minY, labelZOffset, false); + shape.addVertex(minX + cw, minY, labelZOffset, true); + shape.addVertex(minX + tw - cw, minY, labelZOffset, true); + shape.addVertex(minX + tw, minY, labelZOffset, false); + shape.addVertex(minX + tw, minY + ch, labelZOffset, true); + shape.addVertex(minX + tw, minY + th- ch, labelZOffset, true); + shape.addVertex(minX + tw, minY + th, labelZOffset, false); + shape.addVertex(minX + tw - cw, minY + th, labelZOffset, true); + shape.addVertex(minX + cw, minY + th, labelZOffset, true); + shape.addVertex(minX, minY + th, labelZOffset, false); + shape.addVertex(minX, minY + th - ch, labelZOffset, true); + shape.closeLastOutline(); + } + + public float getCorner() { + return corner; + } + + public void setCorner(float corner) { + if(corner > 1.0f){ + this.corner = 1.0f; + } + else if(corner < 0.01f){ + this.corner = 0.0f; + } + else{ + this.corner = corner; + } + setDirty(true); + } + + public float getLabelZOffset() { + return labelZOffset; + } + + public void setLabelZOffset(float labelZOffset) { + this.labelZOffset = -labelZOffset; + setDirty(true); + } + public float getSpacing() { + return spacing; + } + + public void setSpacing(float spacing) { + if(spacing < 0.0f){ + this.spacing = 0.0f; + } + else{ + this.spacing = spacing; + } + setDirty(true); + } + + public float[] getButtonColor() { + return buttonColor; + } + + public void setButtonColor(float r, float g, float b) { + this.buttonColor[0] = r; + this.buttonColor[1] = g; + this.buttonColor[2] = b; + } + + public float[] getLabelColor() { + return labelColor; + } + + public void setLabelColor(float r, float g, float b) { + this.labelColor[0] = r; + this.labelColor[1] = g; + this.labelColor[2] = b; + } + + public String toString(){ + return "RIButton [ label: " + getLabel() + "," + "spacing: " + spacing + + ", " + "corner: " + corner + ", " + "shapeOffset: " + labelZOffset + " ]"; + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIControl.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIControl.java new file mode 100644 index 000000000..c7f0d8dc6 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIControl.java @@ -0,0 +1,53 @@ +package com.jogamp.opengl.test.junit.graph.demos.ui; + +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.geom.AABBox; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; + +public abstract class UIControl { + protected Font font = null; + protected OutlineShape shape = null; + protected String label = "Label"; + protected Factory<? extends Vertex> factory; + + protected boolean dirty = true; + + public UIControl(Factory<? extends Vertex> factory){ + this.factory = factory; + } + + public abstract void generate(AABBox lbox); + + public Font getFont() { + return font; + } + + public void setFont(Font font) { + this.font = font; + } + + public OutlineShape getShape(AABBox lbox) { + if(isDirty()){ + generate(lbox); + } + return shape; + } + + public String getLabel(){ + return label; + } + public void setLabel(String label) { + this.label = label; + setDirty(true); + } + + protected boolean isDirty() { + return dirty; + } + + protected void setDirty(boolean dirty) { + this.dirty = dirty; + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java new file mode 100644 index 000000000..cb373d014 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java @@ -0,0 +1,103 @@ +/** + * 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 com.jogamp.opengl.test.junit.graph.demos.ui; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; + +import jogamp.graph.curve.text.GlyphString; + +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.curve.opengl.TextRenderer; +import com.jogamp.graph.geom.opengl.SVertex; +import com.jogamp.opengl.test.junit.graph.demos.MSAATool; + +public class UIGLListener01 extends UIListenerBase01 { + + public UIGLListener01 (boolean debug, boolean trace) { + super(RegionRenderer.create(SVertex.factory(), Region.SINGLE_PASS), + TextRenderer.create(SVertex.factory(), Region.SINGLE_PASS), debug, trace); + setMatrix(-20, 00, 0f, -50); + button = new RIButton(SVertex.factory(), "Click me!"); + button.setLabelColor(1.0f,1.0f,1.0f); + button.setButtonColor(0.6f,0.6f,0.6f); + button.setCorner(0.5f); + button.setSpacing(0.3f); + System.err.println(button); + } + + private GlyphString glyphString; + public void init(GLAutoDrawable drawable) { + super.init(drawable); + + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + final RegionRenderer regionRenderer = getRegionRenderer(); + final TextRenderer textRenderer = getTextRenderer(); + + gl.setSwapInterval(1); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL); + + regionRenderer.init(gl); + regionRenderer.setAlpha(gl, 1.0f); + + glyphString = textRenderer.createString(gl, button.getFont(), 10, button.getLabel(), 0.5f); + glyphString.generateRegion(gl.getContext(), 0.5f, regionRenderer.getShaderState(), regionRenderer.getRenderType()); + + button.generate(glyphString.getBounds()); + MSAATool.dump(drawable); + } + + 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 = getRegionRenderer(); + + regionRenderer.resetModelview(null); + + regionRenderer.translate(null, getXTran(), getYTran(), getZoom()); + regionRenderer.rotate(gl, getAngle(), 0, 1, 0); + float[] bColor = button.getButtonColor(); + regionRenderer.setColor(gl, bColor[0], bColor[1], bColor[2]); + regionRenderer.renderOutlineShape(gl, button.getShape(glyphString.getBounds()), getPosition(), 0); + float[] lColor = button.getLabelColor(); + regionRenderer.setColor(gl, lColor[0], lColor[1], lColor[2]); + glyphString.renderString3D(); + } + public void dispose(GLAutoDrawable drawable) { + super.dispose(drawable); + glyphString.destroy(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java new file mode 100644 index 000000000..fb4d1015e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -0,0 +1,326 @@ +/** + * 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 com.jogamp.opengl.test.junit.graph.demos.ui; + +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.RegionRenderer; +import com.jogamp.graph.curve.opengl.TextRenderer; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.graph.demos.Screenshot; + +/** + * + * Action Keys: + * - 1/2: zoom in/out + * - 4/5: increase/decrease shape/text spacing + * - 6/7: increase/decrease corner size + * - 0/9: rotate + * - v: toggle v-sync + * - s: screenshot + */ +public abstract class UIListenerBase01 implements GLEventListener { + private Screenshot screenshot; + private RegionRenderer rRenderer; + private TextRenderer tRenderer; + private boolean debug; + private boolean trace; + + protected RIButton button; + + private KeyAction keyAction; + private MouseAction mouseAction; + + 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; + + boolean ignoreInput = false; + + public UIListenerBase01(RegionRenderer rRenderer, TextRenderer tRenderer, boolean debug, boolean trace) { + this.rRenderer = rRenderer; + this.tRenderer = tRenderer; + this.debug = debug; + this.trace = trace; + this.screenshot = new Screenshot(); + } + + public final RegionRenderer getRegionRenderer() { return rRenderer; } + public final TextRenderer getTextRenderer() { return tRenderer; } + 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 float[] getPosition() { return position; } + + public void setMatrix(float xtrans, float ytrans, float angle, int zoom) { + this.xTran = xtrans; + this.yTran = ytrans; + this.ang = angle; + this.zoom = zoom; + } + + 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); + rRenderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 7000.0f); + tRenderer.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(); + rRenderer.dispose(gl); + tRenderer.dispose(gl); + } + + public void zoom(int v){ + zoom += v; + dumpMatrix(); + } + + public void move(float x, float y){ + xTran += x; + yTran += y; + dumpMatrix(); + } + public void rotate(float delta){ + ang += delta; + ang %= 360.0f; + 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); + } + if ( null == mouseAction ) { + mouseAction = new MouseAction(); + window.addMouseListener(mouseAction); + } + } + + public void detachFrom(GLWindow window) { + if ( null == keyAction ) { + return; + } + if ( null == mouseAction ) { + return; + } + window.removeGLEventListener(this); + window.removeKeyListener(keyAction); + window.removeMouseListener(mouseAction); + } + + 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), 0, objName); + + String filename = dir + tech + sw +".tga"; + screenshot.surface2File(drawable, filename /*, exportAlpha */); + } + + int screenshot_num = 0; + + public void setIgnoreInput(boolean v) { + ignoreInput = v; + } + public boolean getIgnoreInput() { + return ignoreInput; + } + + public class MouseAction implements MouseListener{ + + public void mouseClicked(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + button.setLabelColor(0.8f,0.8f,0.8f); + button.setButtonColor(0.1f, 0.1f, 0.1f); + } + + public void mouseReleased(MouseEvent e) { + button.setLabelColor(1.0f,1.0f,1.0f); + button.setButtonColor(0.6f,0.6f,0.6f); + } + + @Override + public void mouseMoved(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseDragged(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseWheelMoved(MouseEvent e) { + // TODO Auto-generated method stub + + } + + } + + public class KeyAction implements KeyListener { + public void keyPressed(KeyEvent arg0) { + if(ignoreInput) { + return; + } + + 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_4){ + button.setSpacing(button.getSpacing()-0.1f); + System.err.println("Button Spacing: " + button.getSpacing()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_5){ + button.setSpacing(button.getSpacing()+0.1f); + System.err.println("Button Spacing: " + button.getSpacing()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_6){ + button.setCorner(button.getCorner()-0.1f); + System.err.println("Button Corner: " + button.getCorner()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_7){ + button.setCorner(button.getCorner()+0.1f); + System.err.println("Button Corner: " + button.getCorner()); + } + 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); + } + }); + } + } + else if(arg0.getKeyCode() == KeyEvent.VK_S){ + rotate(-1); + if(null != autoDrawable) { + autoDrawable.invoke(false, new GLRunnable() { + public void run(GLAutoDrawable drawable) { + try { + final String type = ( 1 == rRenderer.getRenderType() ) ? "r2t0-msaa1" : "r2t1-msaa0" ; + printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false); + screenshot_num++; + } catch (GLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + } + } + } + public void keyTyped(KeyEvent arg0) {} + public void keyReleased(KeyEvent arg0) {} + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java new file mode 100755 index 000000000..98e74e3a6 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java @@ -0,0 +1,73 @@ +/** + * 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 com.jogamp.opengl.test.junit.graph.demos.ui; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +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 UINewtDemo01 { + static final boolean DEBUG = false; + static final boolean TRACE = false; + + public static void main(String[] args) { + GLProfile.initSingleton(true); + GLProfile glp = GLProfile.getGL2ES2(); + GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(4); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + System.out.println("Requested: " + caps); + + GLWindow window = GLWindow.create(caps); + window.setPosition(10, 10); + window.setSize(800, 400); + window.setTitle("GPU UI Newt Demo 01"); + + UIGLListener01 uiGLListener = new UIGLListener01 (DEBUG, TRACE); + uiGLListener.attachInputListenerTo(window); + window.addGLEventListener(uiGLListener); + + window.enablePerfLog(true); + window.setVisible(true); + + Animator animator = new Animator(); + animator.add(window); + animator.start(); + } +} |