1package com.jogamp.opengl.test.junit.newt;
3import java.io.IOException;
4import java.util.Random;
6import com.jogamp.nativewindow.AbstractGraphicsDevice;
7import com.jogamp.opengl.GLAutoDrawable;
8import com.jogamp.opengl.GLCapabilities;
9import com.jogamp.opengl.GLCapabilitiesImmutable;
10import com.jogamp.opengl.GLEventListener;
11import com.jogamp.opengl.GLProfile;
13import org.junit.Assert;
14import org.junit.BeforeClass;
16import org.junit.FixMethodOrder;
17import org.junit.runners.MethodSorters;
19import com.jogamp.newt.Screen;
20import com.jogamp.newt.event.MouseAdapter;
21import com.jogamp.newt.event.MouseEvent;
22import com.jogamp.newt.opengl.GLWindow;
23import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
24import com.jogamp.opengl.test.junit.util.UITestCase;
25import com.jogamp.opengl.util.Animator;
27@FixMethodOrder(MethodSorters.NAME_ASCENDING)
30 static int width, height;
31 static long durationPerTest = 2000;
41 throws InterruptedException
43 Assert.assertNotNull(caps);
50 Assert.assertNotNull(glWindow);
52 glWindow = GLWindow.
create(caps);
53 Assert.assertNotNull(glWindow);
62 Assert.assertEquals(
true,glWindow.
isVisible());
68 static void destroyWindow(
final GLWindow glWindow) {
71 Assert.assertEquals(
false,glWindow.isNativeValid());
85 void testWarpImpl(
final boolean random)
throws InterruptedException {
87 Assert.assertNotNull(caps);
88 final GLWindow window1 = createWindow(
null, caps);
90 Assert.assertEquals(
true,window1.
isVisible());
93 animator.
add(window1);
108 public void mouseEntered(
final MouseEvent e) {
112 public void mouseExited(
final MouseEvent e) {
117 public void mouseMoved(
final MouseEvent e) {
123 final Random r =
new Random();
125 void warpRandom(
final int width,
final int height) {
126 final int x = r.nextInt(width);
127 final int y = r.nextInt(height);
132 public void init(
final GLAutoDrawable drawable) {}
135 public void dispose(
final GLAutoDrawable drawable) {}
138 public void display(
final GLAutoDrawable drawable) {
139 warpRandom(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
143 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {}
152 destroyWindow(window1);
155 static int atoi(
final String a) {
158 i = Integer.parseInt(a);
159 }
catch (
final Exception ex) { ex.printStackTrace(); }
163 public static void main(
final String args[])
throws IOException {
164 for(
int i=0; i<args.length; i++) {
165 if(args[i].equals(
"-time")) {
166 durationPerTest = atoi(args[++i]);
169 System.out.println(
"durationPerTest: "+durationPerTest);
171 org.junit.runner.JUnitCore.
main(tstname);
abstract AbstractGraphicsDevice getGraphicsDevice()
Return the AbstractGraphicsDevice used for depending resources lifecycle, i.e.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract Display getDisplay()
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void warpPointer(final int x, final int y)
Moves the pointer to x/y relative to this window's origin in pixel units.
final boolean isNativeValid()
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
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 isVisible()
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final void requestFocus()
Request focus for this native window.
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 String glAvailabilityToString(final AbstractGraphicsDevice device)
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
static void main(final String args[])
final long getTotalFPSDuration()
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
A interface describing a graphics device in a toolkit-independent manner.
String getConnection()
Returns the semantic GraphicsDevice connection.
void setUpdateFPSFrames(int frames, PrintStream out)
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.