JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestTextureSequence01NEWT.java
Go to the documentation of this file.
1package com.jogamp.opengl.test.junit.jogl.util.texture;
2
3import java.io.IOException;
4
5import com.jogamp.opengl.GLAutoDrawable;
6import com.jogamp.opengl.GLCapabilities;
7import com.jogamp.opengl.GLEventListener;
8import com.jogamp.opengl.GLProfile;
9
10import org.junit.Assert;
11import org.junit.BeforeClass;
12import org.junit.Test;
13import org.junit.FixMethodOrder;
14import org.junit.runners.MethodSorters;
15
16import com.jogamp.newt.opengl.GLWindow;
17import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
18import com.jogamp.opengl.test.junit.util.MiscUtils;
19import com.jogamp.opengl.test.junit.util.QuitAdapter;
20import com.jogamp.opengl.test.junit.util.UITestCase;
21import com.jogamp.opengl.util.Animator;
22import com.jogamp.opengl.util.texture.ImageSequence;
23import com.jogamp.opengl.util.texture.TextureIO;
24
25@FixMethodOrder(MethodSorters.NAME_ASCENDING)
27 static boolean showFPS = false;
28 static int width = 510;
29 static int height = 300;
30 static boolean useBuildInTexLookup = false;
31 static long duration = 500; // ms
32 static GLProfile glp;
33 static GLCapabilities caps;
34
35 @BeforeClass
36 public static void initClass() {
37 glp = GLProfile.getGL2ES2();
38 Assert.assertNotNull(glp);
39 caps = new GLCapabilities(glp);
40 Assert.assertNotNull(caps);
41 }
42
43 void testImpl() throws InterruptedException {
44 final GLWindow window = GLWindow.create(caps);
45 window.setTitle("TestTextureSequence01NEWT");
46 // Size OpenGL to Video Surface
47 window.setSize(width, height);
48 final ImageSequence texSource = new ImageSequence(0, useBuildInTexLookup);
50 @Override
51 public void init(final GLAutoDrawable drawable) {
52 try {
53 texSource.addFrame(drawable.getGL(), TestTextureSequence01NEWT.class, "test-ntscP_3-01-160x90.png", TextureIO.PNG);
54 } catch (final IOException e) {
55 e.printStackTrace();
56 }
57 }
58 @Override
59 public void dispose(final GLAutoDrawable drawable) { }
60 @Override
61 public void display(final GLAutoDrawable drawable) { }
62 @Override
63 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
64 });
65 window.addGLEventListener(new TextureSequenceCubeES2(texSource, false, -2.3f, 0f, 0f));
66 final Animator animator = new Animator(window);
67 animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
68 final QuitAdapter quitAdapter = new QuitAdapter();
69 window.addKeyListener(quitAdapter);
70 window.addWindowListener(quitAdapter);
71 animator.start();
72 window.setVisible(true);
73
74 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
75 Thread.sleep(100);
76 }
77
78 animator.stop();
79 Assert.assertFalse(animator.isAnimating());
80 Assert.assertFalse(animator.isStarted());
81 window.destroy();
82 }
83
84 @Test
85 public void test1() throws InterruptedException {
86 testImpl();
87 }
88
89 public static void main(final String[] args) {
90 for(int i=0; i<args.length; i++) {
91 if(args[i].equals("-time")) {
92 i++;
93 duration = MiscUtils.atol(args[i], duration);
94 } else if(args[i].equals("-width")) {
95 i++;
96 width = MiscUtils.atoi(args[i], width);
97 } else if(args[i].equals("-height")) {
98 i++;
99 height = MiscUtils.atoi(args[i], height);
100 } else if(args[i].equals("-shaderBuildIn")) {
101 useBuildInTexLookup = true;
102 }
103 }
104 org.junit.runner.JUnitCore.main(TestTextureSequence01NEWT.class.getName());
105 }
106
107}
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void setTitle(final String title)
Definition: GLWindow.java:297
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
Definition: GLWindow.java:902
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
Definition: GLWindow.java:882
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Definition: GLProfile.java:913
static int atoi(final String str, final int def)
Definition: MiscUtils.java:57
static long atol(final String str, final long def)
Definition: MiscUtils.java:66
Simple TextureSequence implementation allowing existing textures or image streams to be used and repl...
final TextureSequence.TextureFrame addFrame(final GL gl, final Texture tex)
static final String PNG
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
Definition: TextureIO.java:171
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.