29package com.jogamp.opengl.test.junit.jogl.demos.gl2.newt;
31import com.jogamp.nativewindow.*;
32import com.jogamp.opengl.*;
34import com.jogamp.opengl.util.Animator;
35import com.jogamp.opengl.test.junit.util.GLTestUtil;
36import com.jogamp.opengl.test.junit.util.MiscUtils;
37import com.jogamp.opengl.test.junit.util.UITestCase;
38import com.jogamp.opengl.test.junit.util.QuitAdapter;
39import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
40import com.jogamp.newt.*;
41import com.jogamp.newt.event.*;
42import com.jogamp.newt.opengl.*;
44import org.junit.Assert;
45import org.junit.BeforeClass;
46import org.junit.AfterClass;
48import org.junit.FixMethodOrder;
49import org.junit.runners.MethodSorters;
51@FixMethodOrder(MethodSorters.NAME_ASCENDING)
54 static int width, height;
55 static boolean useAnimator =
true;
56 static boolean doResizeTest =
true;
57 static long duration = 500;
62 Assert.assertNotNull(glp);
77 Assert.assertNotNull(glWindow);
78 glWindow.
setTitle(
"Gears NewtAWTWrapper Test");
93 glWindow.
setSize(width/div, height/div);
98 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glWindow.
getSurfaceWidth()+
"x"+glWindow.
getSurfaceHeight(),
103 glWindow.
setSize(width/div, height/div);
105 expSurfaceSize[0] = width/div;
106 expSurfaceSize[1] = height/div;
108 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glWindow.
getSurfaceWidth()+
"x"+glWindow.
getSurfaceHeight(),
113 glWindow.
setSize(width/div, height/div);
115 expSurfaceSize[0] = width/div;
116 expSurfaceSize[1] = height/div;
118 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glWindow.
getSurfaceWidth()+
"x"+glWindow.
getSurfaceHeight(),
123 final long t0 = System.currentTimeMillis();
125 while(!quitAdapter.shouldQuit() && t1-t0<duration) {
127 t1 = System.currentTimeMillis();
137 public void test01() throws InterruptedException {
142 public static void main(
final String args[]) {
143 for(
int i=0; i<args.length; i++) {
144 if(args[i].equals(
"-time")) {
147 }
else if(args[i].equals(
"-noanim")) {
149 }
else if(args[i].equals(
"-noresize")) {
150 doResizeTest =
false;
153 System.err.println(
"useAnimator "+useAnimator);
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
static final String TYPE_AWT
Generic AWT type, as retrieved with getNativeWindowType(boolean).
static Display createDisplay(final String name)
Create a Display entity.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final void setTitle(final String title)
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
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 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 void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
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 GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
void runTestGL(final GLCapabilitiesImmutable caps)
static void main(final String args[])
static void releaseClass()
static boolean waitForSize(final GLDrawable drawable, final int width, final int height, final Runnable waitAction)
static long atol(final String str, final long def)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
int[] convertToPixelUnits(final int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
Specifying NEWT's Window functionality:
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.