29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.io.BufferedReader;
32import java.io.IOException;
33import java.io.InputStreamReader;
35import com.jogamp.common.util.InterruptSource;
36import com.jogamp.newt.event.KeyAdapter;
37import com.jogamp.newt.event.KeyEvent;
38import com.jogamp.newt.event.WindowEvent;
39import com.jogamp.newt.event.WindowAdapter;
40import com.jogamp.newt.opengl.GLWindow;
41import com.jogamp.opengl.test.junit.util.MiscUtils;
42import com.jogamp.opengl.test.junit.util.NewtTestUtil;
43import com.jogamp.opengl.test.junit.util.UITestCase;
44import com.jogamp.opengl.test.junit.util.QuitAdapter;
46import com.jogamp.opengl.util.Animator;
47import com.jogamp.opengl.util.GLReadBufferUtil;
48import com.jogamp.opengl.util.texture.TextureIO;
50import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2;
52import com.jogamp.opengl.GLAutoDrawable;
53import com.jogamp.opengl.GLCapabilities;
54import com.jogamp.opengl.GLCapabilitiesImmutable;
55import com.jogamp.opengl.GLEventListener;
56import com.jogamp.opengl.GLProfile;
58import org.junit.Assert;
59import org.junit.AfterClass;
61import org.junit.FixMethodOrder;
62import org.junit.runners.MethodSorters;
64@FixMethodOrder(MethodSorters.NAME_ASCENDING)
66 static long duration = 1000;
67 static int swapInterval = 1;
68 static boolean showFPS =
false;
69 static boolean forceES2 =
false;
70 static boolean doRotate =
true;
71 static boolean demo0Only =
false;
72 static int globalNumSamples = 0;
73 static boolean manual =
false;
81 System.err.println(
"requested: vsync "+swapInterval+
", "+caps);
83 Assert.assertNotNull(glWindow);
84 glWindow.
setTitle(
"Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+
"), swapInterval "+swapInterval);
111 System.err.println(
"XXX: "+dw+
"x"+dh+
", c "+c);
117 }
else if( 6 == c ) {
118 new InterruptSource.Thread() {
121 glWindow.
setSize(dw+64, dh+64);
123 }
else if( 9 == c ) {
125 }
else if( 12 == c ) {
127 }
else if( 15 == c ) {
128 new InterruptSource.Thread() {
131 glWindow.
setSize(dw+128, dh+128);
133 }
else if( 18 == c ) {
135 new InterruptSource.Thread() {
138 glWindow.
setSize(dw+256, dh+256);
144 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
165 public void keyReleased(
final KeyEvent e) {
169 System.err.println(
"*** "+e);
171 new InterruptSource.Thread() {
181 System.err.println(
"*** "+num);
182 if(0 <= num && num <= 8) {
183 System.err.println(
"MSAA: "+demo.
getMSAA()+
" -> "+num);
201 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
206 Assert.assertFalse(animator.isAnimating());
207 Assert.assertFalse(animator.
isStarted());
217 runTestGL(caps, globalNumSamples);
223 if( manual ) return ;
231 if( manual ) return ;
237 public static void main(
final String args[])
throws IOException {
238 boolean waitForKey =
false;
242 for(
int i=0; i<args.length; i++) {
243 if(args[i].equals(
"-time")) {
246 }
else if(args[i].equals(
"-vsync")) {
249 }
else if(args[i].equals(
"-es2")) {
251 }
else if(args[i].equals(
"-showFPS")) {
253 }
else if(args[i].equals(
"-samples")) {
255 globalNumSamples =
MiscUtils.
atoi(args[i], globalNumSamples);
256 }
else if(args[i].equals(
"-norotate")) {
258 }
else if(args[i].equals(
"-demo0Only")) {
260 }
else if(args[i].equals(
"-wait")) {
262 }
else if(args[i].equals(
"-manual")) {
267 System.err.println(
"swapInterval "+swapInterval);
268 System.err.println(
"forceES2 "+forceES2);
269 System.err.println(
"manual "+manual);
272 final BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
273 System.err.println(
"Press enter to continue");
275 System.err.println(stdin.readLine());
276 }
catch (
final IOException e) { }
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
final char getKeyChar()
Returns the UTF-16 character reflecting the key symbol incl.
static boolean isPrintableKey(final short uniChar, final boolean isKeyChar)
Returns true if given uniChar represents a printable character, i.e.
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final boolean isFullscreen()
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final void setTitle(final String title)
final int getX()
Returns the current x position of this window, relative to it's parent.
final boolean isAlwaysOnTop()
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
final CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
void runTestGL(final GLCapabilitiesImmutable caps, final int numSamples)
static void main(final String args[])
static void releaseClass()
void setDemo0Only(final boolean v)
void setDoRotation(final boolean rotate)
void setMSAA(final int numSamples)
static int atoi(final String str, final int def)
static long atol(final String str, final long def)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
final long getTotalFPSDuration()
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.
final synchronized boolean stop()
Stops this animator.
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
static final String PNG
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
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.
Specifies an immutable set of OpenGL capabilities.
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.