JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestES1FixedFunctionPipelineNEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 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.util;
30
31import com.jogamp.newt.opengl.GLWindow;
32import com.jogamp.opengl.test.junit.util.UITestCase;
33import com.jogamp.opengl.test.junit.util.QuitAdapter;
34
35import com.jogamp.opengl.util.Animator;
36
37import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
38import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
39
40import com.jogamp.opengl.GLCapabilities;
41import com.jogamp.opengl.GLEventListener;
42import com.jogamp.opengl.GLProfile;
43
44import org.junit.Assert;
45import org.junit.BeforeClass;
46import org.junit.AfterClass;
47import org.junit.Test;
48import org.junit.FixMethodOrder;
49import org.junit.runners.MethodSorters;
50
51@FixMethodOrder(MethodSorters.NAME_ASCENDING)
53 static int width, height;
54
55 @BeforeClass
56 public static void initClass() {
57 width = 512;
58 height = 512;
59 }
60
61 @AfterClass
62 public static void releaseClass() {
63 }
64
65 protected void runTestGL0(final GLCapabilities caps, final GLEventListener demo) throws InterruptedException {
66 final GLWindow glWindow = GLWindow.create(caps);
67 Assert.assertNotNull(glWindow);
68 glWindow.setTitle(getSimpleTestName("."));
69
70 glWindow.addGLEventListener(demo);
72 snap.setPostSNDetail(demo.getClass().getSimpleName());
73 glWindow.addGLEventListener(snap);
74
75 final Animator animator = new Animator(glWindow);
76 final QuitAdapter quitAdapter = new QuitAdapter();
77 glWindow.addKeyListener(quitAdapter);
78 glWindow.addWindowListener(quitAdapter);
79
80 glWindow.setSize(width, height);
81 glWindow.setVisible(true);
82 animator.setUpdateFPSFrames(1, null);
83 animator.start();
84
85 snap.setMakeSnapshot();
86 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
87 Thread.sleep(100);
88 }
89 glWindow.removeGLEventListener(demo);
90
91 animator.stop();
92 glWindow.destroy();
93 }
94
95 protected void runTestGL(final GLCapabilities caps, final boolean forceFFPEmu) throws InterruptedException {
96 final RedSquareES1 demo01 = new RedSquareES1();
97 demo01.setForceFFPEmu(forceFFPEmu, false, false, false);
98 runTestGL0(caps, demo01);
99
100 final GearsES1 demo02 = new GearsES1();
101 demo02.setForceFFPEmu(forceFFPEmu, false, false, false);
102 runTestGL0(caps, demo02);
103
104 final DemoGL2ES1ImmModeSink demo03 = new DemoGL2ES1ImmModeSink(true);
105 demo03.setForceFFPEmu(forceFFPEmu, false, false, false);
106 runTestGL0(caps, demo03);
107
109 demo04.setForceFFPEmu(forceFFPEmu, false, false, false);
110 runTestGL0(caps, demo04);
111 }
112
113 @Test
114 public void test01GL2Normal() throws InterruptedException {
115 if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
117 runTestGL(caps, false);
118 }
119
120 @Test
121 public void test02GL2FFPEmu() throws InterruptedException {
122 if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
124 runTestGL(caps, true);
125 }
126
127 @Test
128 public void test03GL2ES1Normal() throws InterruptedException {
129 if(!GLProfile.isAvailable(GLProfile.GL2ES1)) { System.err.println("GL2ES1 n/a"); return; }
131 runTestGL(caps, false);
132 }
133
134 @Test
135 public void test04ES2FFPEmu() throws InterruptedException {
136 if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
138 runTestGL(caps, false); // should be FFPEmu implicit
139 }
140
141 static long duration = 1000; // ms
142
143 public static void main(final String args[]) {
144 for(int i=0; i<args.length; i++) {
145 if(args[i].equals("-time")) {
146 i++;
147 try {
148 duration = Integer.parseInt(args[i]);
149 } catch (final Exception ex) { ex.printStackTrace(); }
150 }
151 }
152 org.junit.runner.JUnitCore.main(TestES1FixedFunctionPipelineNEWT.class.getName());
153 }
154}
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 boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
Definition: GLProfile.java:305
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
static final String GL2ES1
The intersection of the desktop GL2 and embedded ES1 profile.
Definition: GLProfile.java:591
void setForceFFPEmu(final boolean forceFFPEmu, final boolean verboseFFPEmu, final boolean debugFFPEmu, final boolean traceFFPEmu)
Definition: GearsES1.java:90
void setForceFFPEmu(final boolean forceFFPEmu, final boolean verboseFFPEmu, final boolean debugFFPEmu, final boolean traceFFPEmu)
void setForceFFPEmu(final boolean forceFFPEmu, final boolean verboseFFPEmu, final boolean debugFFPEmu, final boolean traceFFPEmu)
void runTestGL0(final GLCapabilities caps, final GLEventListener demo)
final void setUpdateFPSFrames(final int frames, final PrintStream out)
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.
GLEventListener removeGLEventListener(GLEventListener listener)
Removes the given listener from this drawable queue.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.