From fa9f2883664ba015f778c32df9aa69897db63d55 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 19 May 2014 23:35:06 +0200 Subject: Bug 801: Split GraphUI's TextureButton: TextureSeqButton (Base) and it's derivations ImageSeqButton + GLEventListenerButton + MediaPlayerButton Split GraphUI's TextureButton to TextureSeqButton (Base) and it's derivations: - ImageSeqButton - displays an ImageSequence - GLEventListenerButton - displays any GLEventListener as rendered into FBO as an ImageSequence - MediaPlayerButton - displays movies - Added public ImageSequence impl. TextureSequence, was private SingleTextureSeqFrame. - Demo GPUUISceneGLListener0A shows: - MediaPlayerButton w/ Big Buck Bunny film - GLEventListenerButton w/ GearsES2 - ImageSeqButton w/ 2 textures (pressed/released) --- .../junit/graph/demos/GPUUISceneGLListener0A.java | 194 +++++++++++---------- .../test/junit/graph/demos/GPUUISceneNewtDemo.java | 16 +- .../junit/graph/demos/button-pressed-145x53.png | Bin 0 -> 8603 bytes .../junit/graph/demos/button-released-145x53.png | Bin 0 -> 9429 bytes .../graph/demos/ui/GLEventListenerButton.java | 131 ++++++++++++++ .../test/junit/graph/demos/ui/ImageSeqButton.java | 63 +++++++ .../junit/graph/demos/ui/MediaPlayerButton.java | 131 ++++++++++++++ .../test/junit/graph/demos/ui/TextureButton.java | 84 --------- .../junit/graph/demos/ui/TextureSeqButton.java | 79 +++++++++ .../jogl/util/texture/SingleTextureSeqFrame.java | 126 ------------- .../util/texture/TestTextureSequence01AWT.java | 10 +- .../util/texture/TestTextureSequence01NEWT.java | 11 +- 12 files changed, 532 insertions(+), 313 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/button-pressed-145x53.png create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/button-released-145x53.png create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureButton.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index df9c6381f..a2c3faecf 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -32,18 +32,20 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.VectorUtil; import com.jogamp.opengl.test.junit.graph.demos.ui.CrossHair; +import com.jogamp.opengl.test.junit.graph.demos.ui.GLEventListenerButton; import com.jogamp.opengl.test.junit.graph.demos.ui.Label; import com.jogamp.opengl.test.junit.graph.demos.ui.LabelButton; +import com.jogamp.opengl.test.junit.graph.demos.ui.MediaPlayerButton; import com.jogamp.opengl.test.junit.graph.demos.ui.RoundButton; import com.jogamp.opengl.test.junit.graph.demos.ui.SceneUIController; -import com.jogamp.opengl.test.junit.graph.demos.ui.TextureButton; +import com.jogamp.opengl.test.junit.graph.demos.ui.ImageSeqButton; import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; -import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; -import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; -import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; +import com.jogamp.opengl.util.texture.ImageSequence; +import com.jogamp.opengl.util.texture.TextureIO; public class GPUUISceneGLListener0A implements GLEventListener { @@ -82,6 +84,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { private Label[] labels = null; private String[] strings = null; private final List buttons = new ArrayList(); + private int buttonsLeftCount = 0; private Label truePtSizeLabel = null; private Label jogampLabel = null; private Label fpsLabel = null; @@ -167,15 +170,16 @@ public class GPUUISceneGLListener0A implements GLEventListener { buttons.clear(); final float buttonXSize = buttonXSizePVP * width; - final float buttonYSize = buttonYSizePVP * height; + // final float buttonYSize = buttonYSizePVP * height; + final float buttonYSize = buttonXSize / 2.5f; System.err.println("Button Size: "+buttonXSizePVP+" x "+buttonYSizePVP+" * "+width+" x "+height+" -> "+buttonXSize+" x "+buttonYSize); - final float xstart = 0f; - final float ystart = 0f; + final float xStartLeft = 0f; // aligned to left edge w/ space via reshape + final float yStartTop = 0f; // aligned to top edge w/ space via reshape final float diffX = 1.2f * buttonXSize; final float diffY = 1.5f * buttonYSize; LabelButton button = new LabelButton(SVertex.factory(), renderModes, font, "Next Text", buttonXSize, buttonYSize); - button.translate(xstart,ystart-diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop-diffY*buttons.size(), 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -192,7 +196,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { button = new LabelButton(SVertex.factory(), renderModes, font, "Show FPS", buttonXSize, buttonYSize); button.setName(100); // FIXME: DEBUG tag - button.translate(xstart,ystart - diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); button.setToggleable(true); button.setToggle(fpsLabel.isEnabled()); button.addMouseListener(new UIShape.MouseGestureAdapter() { @@ -208,7 +212,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { buttons.add(button); button = new LabelButton(SVertex.factory(), renderModes, font, "v-sync", buttonXSize, buttonYSize); - button.translate(xstart,ystart - diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); button.setToggleable(true); button.setToggle(gl.getSwapInterval()>0); button.addMouseListener(new UIShape.MouseGestureAdapter() { @@ -231,7 +235,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { buttons.add(button); button = new LabelButton(SVertex.factory(), renderModes, font, "< tilt >", buttonXSize, buttonYSize); - button.translate(xstart,ystart - diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -253,7 +257,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { if( pass2Mode ) { // second column to the left button = new LabelButton(SVertex.factory(), renderModes, font, "< samples >", buttonXSize, buttonYSize); - button.translate(xstart,ystart - diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -279,7 +283,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { buttons.add(button); button = new LabelButton(SVertex.factory(), renderModes, font, "< quality >", buttonXSize, buttonYSize); - button.translate(xstart,ystart - diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -307,7 +311,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { } button = new LabelButton(SVertex.factory(), renderModes, font, "Quit", buttonXSize, buttonYSize); - button.translate(xstart,ystart - diffY*buttons.size(), 0f); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); button.setColor(0.7f, 0.0f, 0.0f, 1.0f); button.setLabelColor(1.2f, 1.2f, 1.2f); button.setPressedColorMod(1.1f, 0.0f, 0.0f, 1.0f); @@ -333,7 +337,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { int j = 1; // column int k = 0; // row button = new LabelButton(SVertex.factory(), renderModes, font, "y flip", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -344,7 +348,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; button = new LabelButton(SVertex.factory(), renderModes, font, "x flip", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -355,7 +359,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; button = new LabelButton(SVertex.factory(), renderModes, font, "+", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -382,7 +386,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; button = new LabelButton(SVertex.factory(), renderModes, font, "< space >", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -406,7 +410,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; button = new LabelButton(SVertex.factory(), renderModes, font, "< corner >", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -431,7 +435,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; button = new LabelButton(SVertex.factory(), renderModes, font, "reset", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -442,7 +446,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; button = new LabelButton(SVertex.factory(), renderModes, font, "screenshot", buttonXSize, buttonYSize); - button.translate(xstart - diffX*j,ystart - diffY*k, 0f); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); button.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -459,75 +463,28 @@ public class GPUUISceneGLListener0A implements GLEventListener { k++; } + buttonsLeftCount = buttons.size(); + + final float button2XSize = 2f*buttonXSize; + final float button2YSize = 2f*buttonYSize; + final float xStartRight = -button2XSize - 8f; // aligned to right edge via reshape + if(true) { final GLMediaPlayer mPlayer = GLMediaPlayerFactory.createDefault(); - final TextureButton texButton = new TextureButton(renderer.getRenderState().getVertexFactory(), renderModes, - 2f*buttonXSize, 2f*buttonYSize, mPlayer) { - @Override - protected void destroyImpl(GL2ES2 gl, RegionRenderer renderer) { - mPlayer.destroy(gl); - } - @Override - public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) { - if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) { - try { - System.err.println("XXX InitGL.pre: "+mPlayer); - mPlayer.initGL(gl); - mPlayer.setAudioVolume( 0f ); - System.err.println("XXX Play.pre: "+mPlayer); - GLMediaPlayer.State r = mPlayer.play(); - System.err.println("XXX Play.post: "+r+", "+mPlayer); - markStateDirty(); - } catch (Exception e) { - e.printStackTrace(); - } - } - super.drawShape(gl, renderer, sampleCount); - markStateDirty(); // keep on going - } }; - texButton.setEnabled(false); // wait until data is avail. (shader) - texButton.translate(xstart + diffX*5, ystart - diffY*1, 0f); - texButton.setToggleable(true); - texButton.setToggle(false); // toggle == false -> mute audio - texButton.setToggleOffColorMod(0f, 1f, 0f, 1.0f); - texButton.addMouseListener(dragZoomRotateListener); - texButton.addMouseListener(new UIShape.MouseGestureAdapter() { + final MediaPlayerButton mPlayerButton = new MediaPlayerButton(renderer.getRenderState().getVertexFactory(), renderModes, + button2XSize, button2YSize, mPlayer); + mPlayerButton.addDefaultEventListener(); + mPlayerButton.translate(xStartRight, yStartTop - diffY*1, 0f); + mPlayerButton.setToggleable(true); + mPlayerButton.setToggle(false); // toggle == false -> mute audio + mPlayerButton.setToggleOffColorMod(0f, 1f, 0f, 1.0f); + mPlayerButton.addMouseListener(dragZoomRotateListener); + mPlayerButton.addMouseListener(new UIShape.MouseGestureAdapter() { @Override public void mouseClicked(MouseEvent e) { - mPlayer.setAudioVolume( texButton.isToggleOn() ? 1f : 0f ); + mPlayer.setAudioVolume( mPlayerButton.isToggleOn() ? 1f : 0f ); } } ); - buttons.add(texButton); - mPlayer.addEventListener(new GLMediaEventListener() { - @Override - public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { - // texButton.markStateDirty(); - } - - @Override - public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { - System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("MovieCube State: "+mp); - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { - texButton.setEnabled(true); // data and shader is available .. - } - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { - // FIXME: mPlayer.resetGLState(); - } - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - new Thread() { - public void run() { - // loop for-ever .. - mPlayer.seek(0); - mPlayer.play(); - } }.start(); - } else if( 0 != ( GLMediaEventListener.EVENT_CHANGE_ERR & event_mask ) ) { - final StreamException se = mPlayer.getStreamException(); - if( null != se ) { - se.printStackTrace(); - } - } - } - }); + buttons.add(mPlayerButton); try { final URI streamLoc = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); mPlayer.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT); @@ -535,6 +492,51 @@ public class GPUUISceneGLListener0A implements GLEventListener { e1.printStackTrace(); } } + if( true ) { + final ImageSequence imgSeq = new ImageSequence(0, true); + final ImageSeqButton imgButton = new ImageSeqButton(renderer.getRenderState().getVertexFactory(), renderModes, + button2XSize, button2YSize, imgSeq); + try { + imgSeq.addFrame(gl, GPUUISceneGLListener0A.class, "button-released-145x53.png", TextureIO.PNG); + imgSeq.addFrame(gl, GPUUISceneGLListener0A.class, "button-pressed-145x53.png", TextureIO.PNG); + } catch (IOException e2) { + e2.printStackTrace(); + } + imgSeq.setManualStepping(true); + imgButton.translate(xStartRight, yStartTop - diffY*2.5f, 0f); + imgButton.addMouseListener(dragZoomRotateListener); + imgButton.addMouseListener(new UIShape.MouseGestureAdapter() { + @Override + public void mousePressed(MouseEvent e) { + imgButton.setCurrentIdx(1); + System.err.println("XXX: "+imgButton); + } + @Override + public void mouseReleased(MouseEvent e) { + imgButton.setCurrentIdx(0); + } } ); + buttons.add(imgButton); + } + if( true ) { + final GearsES2 glel = new GearsES2(0); + glel.setVerbose(false); + glel.setClearColor(new float[] { 0.9f, 0.9f, 0.9f, 1f } ); + final GLEventListenerButton glelButton = new GLEventListenerButton(renderer.getRenderState().getVertexFactory(), renderModes, + button2XSize, button2YSize, + 0, glel, false /* useAlpha */, + (int)(button2XSize), (int)(button2YSize)); + glelButton.setToggleable(true); + glelButton.setToggle(true); // toggle == true -> animation + glelButton.setAnimate(true); + glelButton.translate(xStartRight, yStartTop - diffY*4f, 0f); + glelButton.addMouseListener(dragZoomRotateListener); + glelButton.addMouseListener(new UIShape.MouseGestureAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + glelButton.setAnimate( glelButton.isToggleOn() ); + } } ); + buttons.add(glelButton); + } } private void initTexts() { @@ -547,13 +549,14 @@ public class GPUUISceneGLListener0A implements GLEventListener { " - Z Translation\n"+ " - Ctrl: Y-Rotation (Shift: X-Rotation)\n"+ " - Tilt, Space and Corner\n"+ - " - Their respective action via wheel (shift = other value)\n"+ + " - Their respective action via wheel\n"+ + " (shift = other value)\n"+ "\n"+ "- Mouse Drag On Object\n"+ " - Click on Object and drag mouse\n"+ - " - Notice current postion in status line at bottom\n"+ + " - Current postion in status line at bottom\n"+ "\n"+ - "- Tilt Button Rotate Whole Button Group\n"; + "- Tilt Button Rotate Whole Button Group"; strings[i++] = "abcdefghijklmn\nopqrstuvwxyz\n"+ "ABCDEFGHIJKL\n"+ @@ -711,7 +714,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { if(null == labels[currentText]) { final float pixelSizeFixed = fontSizeFixedPVP * drawable.getHeight(); - final float dyTop = drawable.getHeight() * relTop; + final float dyTop = drawable.getHeight() - 2f*jogampLabel.getLineHeight(); final float dxRight = drawable.getWidth() * relMiddle; labels[currentText] = new Label(renderer.getRenderState().getVertexFactory(), renderModes, font, pixelSizeFixed, strings[currentText]); labels[currentText].setColor(0.1f, 0.1f, 0.1f, 1.0f); @@ -769,15 +772,20 @@ public class GPUUISceneGLListener0A implements GLEventListener { final float dyTop = dh * relTop; final float dxMiddle = dw * relMiddle; final float dxLeft = dw * relLeft; + final float dxRight = dw; - for(int i=0; i factory, final int renderModes, + final float width, final float height, final int textureUnit, + final GLEventListener glel, final boolean useAlpha, final int fboWidth, final int fboHeight) { + super(factory, renderModes, width, height, new ImageSequence(textureUnit, true)); + this.glel = glel; + this.useAlpha = useAlpha; + + setColor(0.95f, 0.95f, 0.95f, 1.0f); + setPressedColorMod(1f, 1f, 1f, 0.9f); + setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); + setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); + + this.fboWidth = fboWidth; + this.fboHeight = fboHeight; + } + + public final void setAnimate(boolean v) { animateGLEL = v; } + public final boolean getAnimate() { return animateGLEL; } + + public final void setFBOSize(final int fboWidth, final int fboHeight) { + this.fboWidth = fboWidth; + this.fboHeight = fboHeight; + } + + public final GLOffscreenAutoDrawable.FBO getFBOAutoDrawable() { return fboGLAD; } + + @Override + public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) { + if( null == fboGLAD ) { + final ImageSequence imgSeq = (ImageSequence)texSeq; + + final GLContext ctx = gl.getContext(); + final GLDrawable drawable = ctx.getGLDrawable(); + final GLCapabilitiesImmutable capsHas = drawable.getChosenGLCapabilities(); + final GLCapabilities caps = (GLCapabilities) capsHas.cloneMutable(); + caps.setFBO(true); + caps.setDoubleBuffered(false); + if( !useAlpha ) { + caps.setAlphaBits(0); + } + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + + fboGLAD = (GLOffscreenAutoDrawable.FBO) factory.createOffscreenAutoDrawable( + drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(), + caps, null, fboWidth, fboHeight); + fboWidth = 0; + fboHeight = 0; + fboGLAD.setSharedContext(ctx); + fboGLAD.setTextureUnit(imgSeq.getTextureUnit()); + fboGLAD.addGLEventListener(glel); + fboGLAD.display(); // 1st init! + + final FBObject.TextureAttachment texA01 = fboGLAD.getTextureBuffer(GL.GL_FRONT); + final Texture tex = new Texture(texA01.getName(), imgSeq.getTextureTarget(), + fboGLAD.getWidth(), fboGLAD.getHeight(), fboGLAD.getWidth(), fboGLAD.getHeight(), + false /* mustFlipVertically */); + imgSeq.addFrame(gl, tex); + markStateDirty(); + } else if( 0 != fboWidth*fboHeight ) { + fboGLAD.setSize(fboWidth, fboHeight); + fboWidth = 0; + fboHeight = 0; + } else if( animateGLEL ) { + fboGLAD.display(); + } + + super.drawShape(gl, renderer, sampleCount); + + if( animateGLEL ) { + markStateDirty(); // keep on going + } + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java new file mode 100644 index 000000000..ca6f79448 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java @@ -0,0 +1,63 @@ +/** + * Copyright 2014 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.GL2ES2; + +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.opengl.util.texture.ImageSequence; + +/** + * GPU based resolution independent {@link ImageSequence} Button impl + */ +public class ImageSeqButton extends TextureSeqButton { + + public ImageSeqButton(final Factory factory, final int renderModes, + final float width, final float height, final ImageSequence texSeq) { + super(factory, renderModes, width, height, texSeq); + setColor(0.95f, 0.95f, 0.95f, 1.0f); + setPressedColorMod(1f, 1f, 1f, 0.9f); + setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); + setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); + } + + public final void setCurrentIdx(final int idx) { + ((ImageSequence)texSeq).setCurrentIdx(idx); + markStateDirty(); + } + + @Override + public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) { + super.drawShape(gl, renderer, sampleCount); + if( !((ImageSequence)texSeq).getManualStepping() ) { + markStateDirty(); // keep on going + } + }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java new file mode 100644 index 000000000..7ec653b62 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java @@ -0,0 +1,131 @@ +/** + * Copyright 2014 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.GL2ES2; + +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; +import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; + +/** + * GPU based resolution independent {@link GLMediaPlayer} Button impl + */ +public class MediaPlayerButton extends TextureSeqButton { + public boolean verbose = false; + + /** + * @param factory + * @param renderModes + * @param width + * @param height + * @param mPlayer + * @param mPlayerListener + */ + public MediaPlayerButton(final Factory factory, final int renderModes, + final float width, final float height, + final GLMediaPlayer mPlayer) { + super(factory, renderModes, width, height, mPlayer); + setColor(0.8f, 0.8f, 0.8f, 1.0f); + setPressedColorMod(1.1f, 1.1f, 1.1f, 0.7f); + setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); + setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); + setEnabled(false); // data and shader n/a yet + } + + /** + * Add the default {@link GLMediaEventListener} to {@link #getGLMediaPlayer() this class's GLMediaPlayer}. + */ + public void addDefaultEventListener() { + getGLMediaPlayer().addEventListener(defGLMediaEventListener); + } + + public final GLMediaPlayer getGLMediaPlayer() { return (GLMediaPlayer)texSeq; } + + private final GLMediaEventListener defGLMediaEventListener = new GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { + // texButton.markStateDirty(); + } + + @Override + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { + final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq; + if( verbose ) { + System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieCube State: "+mp); + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { + MediaPlayerButton.this.setEnabled(true); // data and shader is available .. + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + // FIXME: mPlayer.resetGLState(); + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { + new Thread() { + public void run() { + // loop for-ever .. + mPlayer.seek(0); + mPlayer.play(); + } }.start(); + } else if( 0 != ( GLMediaEventListener.EVENT_CHANGE_ERR & event_mask ) ) { + final StreamException se = mPlayer.getStreamException(); + if( null != se ) { + se.printStackTrace(); + } + } + } }; + + + @Override + protected void destroyImpl(GL2ES2 gl, RegionRenderer renderer) { + ((GLMediaPlayer)texSeq).destroy(gl); + } + + @Override + public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) { + final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq; + if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) { + try { + mPlayer.initGL(gl); + mPlayer.setAudioVolume( 0f ); + mPlayer.play(); + markStateDirty(); + } catch (Exception e) { + e.printStackTrace(); + } + } + super.drawShape(gl, renderer, sampleCount); + markStateDirty(); // keep on going + }; + +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureButton.java deleted file mode 100644 index 5b00d1e3b..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureButton.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2014 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.GL2ES2; - -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.GLRegion; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.util.texture.TextureSequence; - -/** - * GPU based resolution independent Button impl - */ -public class TextureButton extends RoundButton { - private TextureSequence texSeq; - - public TextureButton(final Factory factory, final int renderModes, - final float width, final float height, final TextureSequence texSeq) { - super(factory, renderModes | Region.COLORTEXTURE_RENDERING_BIT, width, height); - this.texSeq = texSeq; - setColor(0.8f, 0.8f, 0.8f, 1.0f); - setPressedColorMod(1.1f, 1.1f, 1.1f, 0.7f); - setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); - setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); - } - - @Override - protected GLRegion createGLRegion() { - return GLRegion.create(getRenderModes(), texSeq); - } - - public void setTextureSequence(final TextureSequence texSeq) { this.texSeq = texSeq; } - public TextureSequence getTextureSequence() { return this.texSeq; } - - @Override - protected void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - if(corner == 0.0f) { - createSharpOutline(shape, 0f); - } else { - createCurvedOutline(shape, 0f); - } - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); - - final float[] ctr = box.getCenter(); - setRotationOrigin( ctr[0], ctr[1], ctr[2]); - - if( DRAW_DEBUG_BOX ) { - System.err.println("XXX.UIShape.TextureButton: Added Shape: "+shape+", "+box); - } - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java new file mode 100644 index 000000000..2a5212566 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java @@ -0,0 +1,79 @@ +/** + * Copyright 2014 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.GL2ES2; + +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.GLRegion; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.opengl.util.texture.TextureSequence; + +/** + * GPU based resolution independent {@link TextureSequence} Button impl + */ +public class TextureSeqButton extends RoundButton { + protected final TextureSequence texSeq; + + public TextureSeqButton(final Factory factory, final int renderModes, + final float width, final float height, final TextureSequence texSeq) { + super(factory, renderModes | Region.COLORTEXTURE_RENDERING_BIT, width, height); + this.texSeq = texSeq; + } + + @Override + protected GLRegion createGLRegion() { + return GLRegion.create(getRenderModes(), texSeq); + } + + public final TextureSequence getTextureSequence() { return this.texSeq; } + + @Override + protected void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer) { + final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + if(corner == 0.0f) { + createSharpOutline(shape, 0f); + } else { + createCurvedOutline(shape, 0f); + } + shape.setIsQuadraticNurbs(); + shape.setSharpness(shapesSharpness); + region.addOutlineShape(shape, null, rgbaColor); + box.resize(shape.getBounds()); + + final float[] ctr = box.getCenter(); + setRotationOrigin( ctr[0], ctr[1], ctr[2]); + + if( DRAW_DEBUG_BOX ) { + System.err.println("XXX.UIShape.TextureSeqButton: Added Shape: "+shape+", "+box); + } + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java deleted file mode 100644 index aef48d82c..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/SingleTextureSeqFrame.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.net.URLConnection; - -import javax.media.opengl.GL; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; -import com.jogamp.opengl.util.texture.TextureSequence; - -public class SingleTextureSeqFrame implements TextureSequence { - TextureSequence.TextureFrame frame = null; - int textureUnit = 0; - protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; - protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; - final boolean useBuildInTexLookup; - - public SingleTextureSeqFrame(boolean useBuildInTexLookup) { - this.useBuildInTexLookup = useBuildInTexLookup; - } - - public void initGLResources(GL gl, Class context, String imageResourcePath, String imageSuffix) throws GLException { - if(null == frame) { - TextureData texData = null; - try { - URLConnection urlConn = IOUtil.getResource(context, imageResourcePath); - if(null != urlConn) { - texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, imageSuffix); - } - } catch (Exception e) { - e.printStackTrace(); - } - final Texture tex = new Texture(gl, texData); - frame = new TextureSequence.TextureFrame(tex); - tex.bind(gl); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_S, texWrapST[0]); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_T, texWrapST[1]); - } - } - - public void destroyGLResources(GL gl) { - if(null != frame) { - frame.getTexture().destroy(gl); - frame = null; - } - } - - public void destroy(GL gl) throws GLException { - frame.getTexture().destroy(gl); - frame = null; - } - - @Override - public int getTextureTarget() { - return GL.GL_TEXTURE_2D; - } - - @Override - public int getTextureUnit() { - return textureUnit; - } - - @Override - public int[] getTextureMinMagFilter() { - return texMinMagFilter; - } - - @Override - public int[] getTextureWrapST() { - return texWrapST; - } - - @Override - public boolean isTextureAvailable() { return true; } - - @Override - public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException { - return frame; // may return null - } - - @Override - public TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException { - return frame; - } - - @Override - public String getRequiredExtensionsShaderStub() throws IllegalStateException { - return "// TextTextureSequence: No extensions required\n"; - } - - @Override - public String getTextureSampler2DType() throws IllegalStateException { - return "sampler2D" ; - } - - private String textureLookupFunctionName = "myTexture2D"; - - @Override - public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { - if(useBuildInTexLookup) { - return "texture2D"; - } - if(null != desiredFuncName && desiredFuncName.length()>0) { - textureLookupFunctionName = desiredFuncName; - } - return textureLookupFunctionName; - } - - @Override - public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { - if(useBuildInTexLookup) { - return ""; - } - return - "\n"+ - "vec4 "+textureLookupFunctionName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ - " return texture2D(image, texCoord);\n"+ - "}\n\n"; - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java index 9dc17dce1..86cf4654e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java @@ -1,6 +1,7 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; import java.awt.Frame; +import java.io.IOException; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -20,6 +21,7 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.texture.ImageSequence; import com.jogamp.opengl.util.texture.TextureIO; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -46,11 +48,15 @@ public class TestTextureSequence01AWT extends UITestCase { Assert.assertNotNull(frame); frame.add(glc); - final SingleTextureSeqFrame texSource = new SingleTextureSeqFrame(useBuildInTexLookup); + final ImageSequence texSource = new ImageSequence(0, useBuildInTexLookup); glc.addGLEventListener(new GLEventListener() { @Override public void init(GLAutoDrawable drawable) { - texSource.initGLResources(drawable.getGL(), TestTextureSequence01AWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG); + try { + texSource.addFrame(drawable.getGL(), TestTextureSequence01AWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG); + } catch (IOException e) { + e.printStackTrace(); + } } @Override public void dispose(GLAutoDrawable drawable) { } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java index c46e334bd..c365b78d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java @@ -1,5 +1,7 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; +import java.io.IOException; + import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; @@ -17,6 +19,7 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.texture.ImageSequence; import com.jogamp.opengl.util.texture.TextureIO; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -42,11 +45,15 @@ public class TestTextureSequence01NEWT extends UITestCase { window.setTitle("TestTextureSequence01NEWT"); // Size OpenGL to Video Surface window.setSize(width, height); - final SingleTextureSeqFrame texSource = new SingleTextureSeqFrame(useBuildInTexLookup); + final ImageSequence texSource = new ImageSequence(0, useBuildInTexLookup); window.addGLEventListener(new GLEventListener() { @Override public void init(GLAutoDrawable drawable) { - texSource.initGLResources(drawable.getGL(), TestTextureSequence01NEWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG); + try { + texSource.addFrame(drawable.getGL(), TestTextureSequence01NEWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG); + } catch (IOException e) { + e.printStackTrace(); + } } @Override public void dispose(GLAutoDrawable drawable) { } -- cgit v1.2.3