JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestElektronenMultipliziererNEWT.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.demos.es2.newt;
30
31import com.jogamp.common.util.InterruptSource;
32import com.jogamp.newt.event.KeyAdapter;
33import com.jogamp.newt.event.KeyEvent;
34import com.jogamp.newt.event.TraceWindowAdapter;
35import com.jogamp.newt.opengl.GLWindow;
36import com.jogamp.opengl.test.junit.util.UITestCase;
37import com.jogamp.opengl.test.junit.util.QuitAdapter;
38
39import com.jogamp.opengl.util.Animator;
40
41import com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer;
42
43import com.jogamp.opengl.GLCapabilitiesImmutable;
44import com.jogamp.opengl.GLProfile;
45
46import org.junit.Assert;
47import org.junit.BeforeClass;
48import org.junit.Test;
49import org.junit.FixMethodOrder;
50import org.junit.runners.MethodSorters;
51
52/**
53 * @see com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer
54 * @author Dominik Ströhlein (DemoscenePassivist), et.al.
55 */
56@FixMethodOrder(MethodSorters.NAME_ASCENDING)
58 static final int width = 640, height = 480;
59
60 static final String tRoutineClassName = null;
61 static final boolean tMultiSampling = false;
62 static final int tNumberOfSampleBuffers = -1;
63 static final boolean tAnisotropicFiltering = false;
64 static final float tAnisotropyLevel = -1.0f;
65 static final boolean tFrameCapture = false;
66 static final boolean tFrameSkip = true;
67 static final int desiredFrameRate = 30;
68 static int startFrame = 1700;
69 static long duration = 5000; // ms
70
71 @BeforeClass
72 public static void initClass() {
73 final GLProfile glp = GLProfile.getDefault();
74 if( ! ( glp.isHardwareRasterizer() && glp.isGL2ES3() ) ) {
75 // Sorry .. mobile ES2 is too slow for this one.
76 setTestSupported(false);
77 return;
78 }
79 }
80
81 protected void run() throws InterruptedException {
83 tRoutineClassName,
84 tMultiSampling,tNumberOfSampleBuffers,
85 tAnisotropicFiltering,tAnisotropyLevel,
86 tFrameCapture,
87 tFrameSkip, desiredFrameRate, startFrame
88 );
90
91 final GLWindow glWindow = GLWindow.create(caps);
92 Assert.assertNotNull(glWindow);
93 glWindow.setSize(width, height);
94 glWindow.setTitle("ElektronenMultiplizierer (GL2ES2/NEWT)");
95 glWindow.addGLEventListener(demo);
96
97 final Animator animator = new Animator(glWindow);
98 animator.setUpdateFPSFrames(60, System.err);
99 final QuitAdapter quitAdapter = new QuitAdapter();
100
101 //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
102 glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
103 glWindow.addKeyListener(quitAdapter);
104 glWindow.addWindowListener(quitAdapter);
105
106 final GLWindow f_glWindow = glWindow;
107 glWindow.addKeyListener(new KeyAdapter() {
108 public void keyReleased(final KeyEvent e) {
109 if( !e.isPrintableKey() || e.isAutoRepeat() ) {
110 return;
111 }
112 if(e.getKeyChar()=='f') {
113 new InterruptSource.Thread() {
114 public void run() {
115 f_glWindow.setFullscreen(!f_glWindow.isFullscreen());
116 } }.start();
117 } else if(e.getKeyChar()=='d') {
118 new InterruptSource.Thread() {
119 public void run() {
120 f_glWindow.setUndecorated(!f_glWindow.isUndecorated());
121 } }.start();
122 }
123 }
124 });
125
126 glWindow.setVisible(true);
127 animator.start();
128
129 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
130 Thread.sleep(100);
131 }
132 animator.stop();
133 glWindow.destroy();
134 }
135
136 @Test
137 public void testElektronenMultiplizierer01() throws InterruptedException {
138 run();
139 }
140
141 public static void main(final String args[]) {
142 for(int i=0; i<args.length; i++) {
143 if(args[i].equals("-time")) {
144 i++;
145 try {
146 duration = Integer.parseInt(args[i]);
147 } catch (final Exception ex) { ex.printStackTrace(); }
148 }
149 if(args[i].equals("-sframe")) {
150 i++;
151 try {
152 startFrame = Integer.parseInt(args[i]);
153 } catch (final Exception ex) { ex.printStackTrace(); }
154 }
155 }
156 org.junit.runner.JUnitCore.main(TestElektronenMultipliziererNEWT.class.getName());
157 }
158}
final boolean isAutoRepeat()
getModifiers() contains AUTOREPEAT_MASK.
final char getKeyChar()
Returns the UTF-16 character reflecting the key symbol incl.
Definition: KeyEvent.java:161
static boolean isPrintableKey(final short uniChar, final boolean isKeyChar)
Returns true if given uniChar represents a printable character, i.e.
Definition: KeyEvent.java:316
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 boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
Definition: GLWindow.java:534
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 setUndecorated(final boolean value)
Definition: GLWindow.java:337
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 the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
Definition: GLProfile.java:739
final boolean isGL2ES3()
Indicates whether this profile is capable of GL2ES3.
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.
Specifies an immutable set of OpenGL capabilities.