JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestOlympicES1NEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.jogl.demos.es1.newt;
30
31import com.jogamp.newt.opengl.GLWindow;
32import com.jogamp.opengl.test.junit.util.MiscUtils;
33import com.jogamp.opengl.test.junit.util.UITestCase;
34import com.jogamp.opengl.test.junit.util.QuitAdapter;
35import com.jogamp.opengl.test.junit.jogl.demos.es1.OlympicES1;
36import com.jogamp.opengl.util.Animator;
37import com.jogamp.opengl.util.AnimatorBase;
38
39import com.jogamp.opengl.GLCapabilities;
40import com.jogamp.opengl.GLProfile;
41
42import org.junit.Assert;
43import org.junit.BeforeClass;
44import org.junit.AfterClass;
45import org.junit.Test;
46import org.junit.FixMethodOrder;
47import org.junit.runners.MethodSorters;
48
49@FixMethodOrder(MethodSorters.NAME_ASCENDING)
50public class TestOlympicES1NEWT extends UITestCase {
51 static int width, height;
52 static boolean forceES2 = false;
53 static boolean forceFFPEmu = false;
54 static boolean verboseFFPEmu = false;
55 static int swapInterval = 1;
56 static boolean exclusiveContext = false;
57
58 @BeforeClass
59 public static void initClass() {
60 width = 640;
61 height = 480;
62 }
63
64 @AfterClass
65 public static void releaseClass() {
66 }
67
68 protected void runTestGL(final GLCapabilities caps) throws InterruptedException {
69 final GLWindow glWindow = GLWindow.create(caps);
70 Assert.assertNotNull(glWindow);
71 glWindow.setTitle("Olympic NEWT Test");
72
73 final OlympicES1 demo = new OlympicES1( swapInterval );
74 demo.setForceFFPEmu(forceFFPEmu, verboseFFPEmu, false, false);
75 glWindow.addGLEventListener(demo);
77 glWindow.addGLEventListener(snap);
78
79 final Animator animator = new Animator(0 /* w/o AWT */);
80 animator.setExclusiveContext(exclusiveContext);
81
82 final QuitAdapter quitAdapter = new QuitAdapter();
83 glWindow.addKeyListener(quitAdapter);
84 glWindow.addWindowListener(quitAdapter);
85 glWindow.setSize(width, height);
86 glWindow.setVisible(true);
87
88 animator.add(glWindow);
89 animator.start();
90 animator.setUpdateFPSFrames(60, System.err);
91 Assert.assertTrue(animator.isStarted());
92 Assert.assertTrue(animator.isAnimating());
93 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
94
95 snap.setMakeSnapshot();
96
97 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
98 Thread.sleep(100);
99 }
100
101 Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread());
102 animator.stop();
103 Assert.assertFalse(animator.isAnimating());
104 Assert.assertFalse(animator.isStarted());
105 Assert.assertEquals(null, glWindow.getExclusiveContextThread());
106 glWindow.destroy();
107 }
108
109 @Test
110 public void test00() throws InterruptedException {
112 runTestGL(caps);
113 }
114
115 static long duration = 500; // ms
116
117 public static void main(final String args[]) {
118 for(int i=0; i<args.length; i++) {
119 if(args[i].equals("-time")) {
120 i++;
121 try {
122 duration = Integer.parseInt(args[i]);
123 } catch (final Exception ex) { ex.printStackTrace(); }
124 } else if(args[i].equals("-vsync")) {
125 i++;
126 swapInterval = MiscUtils.atoi(args[i], swapInterval);
127 } else if(args[i].equals("-exclctx")) {
128 exclusiveContext = true;
129 } else if(args[i].equals("-es2")) {
130 forceES2 = true;
131 } else if(args[i].equals("-ffpemu")) {
132 forceFFPEmu = true;
133 } else if(args[i].equals("-verbose")) {
134 verboseFFPEmu = true;
135 }
136 }
137 System.err.println("forceES2 "+forceES2);
138 System.err.println("forceFFPEmu "+forceFFPEmu);
139 System.err.println("swapInterval "+swapInterval);
140 System.err.println("exclusiveContext "+exclusiveContext);
141 org.junit.runner.JUnitCore.main(TestOlympicES1NEWT.class.getName());
142 }
143}
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 final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
static GLProfile getGL2ES1(final AbstractGraphicsDevice device)
Returns the GL2ES1 profile implementation, hence compatible w/ GL2ES1.
Definition: GLProfile.java:883
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
void setForceFFPEmu(final boolean forceFFPEmu, final boolean verboseFFPEmu, final boolean debugFFPEmu, final boolean traceFFPEmu)
Definition: OlympicES1.java:87
static int atoi(final String str, final int def)
Definition: MiscUtils.java:57
final synchronized Thread getThread()
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized Thread setExclusiveContext(final Thread t)
Dedicate all GLAutoDrawable's context to the given exclusive context thread.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
synchronized boolean isStarted()
Indicates whether this animator has been started.
final synchronized boolean start()
Starts this animator, if not running.
Definition: Animator.java:344
final synchronized boolean stop()
Stops this animator.
Definition: Animator.java:368
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.