29package com.jogamp.opengl.test.junit.jogl.demos.gl2.newt;
31import com.jogamp.nativewindow.ScalableSurface;
32import com.jogamp.nativewindow.util.Dimension;
33import com.jogamp.nativewindow.util.DimensionImmutable;
34import com.jogamp.nativewindow.util.Point;
35import com.jogamp.nativewindow.util.PointImmutable;
36import com.jogamp.newt.opengl.GLWindow;
37import com.jogamp.newt.opengl.util.NEWTDemoListener;
38import com.jogamp.opengl.test.junit.util.UITestCase;
39import com.jogamp.opengl.test.junit.util.MiscUtils;
40import com.jogamp.opengl.test.junit.util.QuitAdapter;
42import com.jogamp.opengl.util.Animator;
44import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
45import com.jogamp.opengl.GLCapabilities;
46import com.jogamp.opengl.GLProfile;
48import org.junit.Assert;
49import org.junit.BeforeClass;
50import org.junit.AfterClass;
52import org.junit.FixMethodOrder;
53import org.junit.runners.MethodSorters;
63@FixMethodOrder(MethodSorters.NAME_ASCENDING)
74 Assert.assertNotNull(glp);
79 setTestSupported(
false);
89 Assert.assertNotNull(glWindow);
90 glWindow.
setTitle(
"Gears NEWT Test");
121 System.err.println(
"window insets: "+glWindow.
getInsets());
122 System.err.println(
"window bounds (window): "+glWindow.
getBounds());
126 System.err.println(
"HiDPI PixelScale: "+reqSurfacePixelScale[0]+
"x"+reqSurfacePixelScale[1]+
" (req) -> "+
127 valReqSurfacePixelScale[0]+
"x"+valReqSurfacePixelScale[1]+
" (val) -> "+
128 hasSurfacePixelScale1[0]+
"x"+hasSurfacePixelScale1[1]+
" (has)");
130 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
139 public void test01() throws InterruptedException {
144 static long duration = 500;
146 public static void main(
final String args[]) {
147 int x=0, y=0, w=640, h=480;
148 boolean usePos =
false;
150 for(
int i=0; i<args.length; i++) {
151 if(args[i].equals(
"-time")) {
154 duration = Integer.parseInt(args[i]);
155 }
catch (
final Exception ex) { ex.printStackTrace(); }
156 }
else if(args[i].equals(
"-width")) {
159 }
else if(args[i].equals(
"-height")) {
162 }
else if(args[i].equals(
"-x")) {
166 }
else if(args[i].equals(
"-y")) {
170 }
else if(args[i].equals(
"-pixelScale")) {
172 final float pS =
MiscUtils.
atof(args[i], reqSurfacePixelScale[0]);
173 reqSurfacePixelScale[0] = pS;
174 reqSurfacePixelScale[1] = pS;
179 wpos =
new Point(x, y);
181 System.err.println(
"position "+wpos);
182 System.err.println(
"size "+wsize);
183 org.junit.runner.JUnitCore.main(
TestGearsNEWT.class.getName());
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final String getStateMaskString()
Returns a string representation of the current state mask.
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
final void setTitle(final String title)
final float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final String getSupportedStateMaskString()
Returns a string representation of the supported state mask.
final Rectangle getSurfaceBounds()
Returns a newly created Rectangle containing window's surface origin and size in pixel units.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final Rectangle getBounds()
Returns a newly created Rectangle containing window origin, getX() & getY(), and size,...
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 boolean setSurfaceScale(final float[] pixelScale)
Request a pixel scale in x- and y-direction for the associated NativeSurface, where size_in_pixel_uni...
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...
NEWT GLWindow Demo functionality.
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
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.
Gears.java author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)
void runTestGL(final GLCapabilities caps)
static void main(final String args[])
static void releaseClass()
static float atof(final String str, final float def)
static int atoi(final String str, final int def)
final long getTotalFPSDuration()
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Adding mutable surface pixel scale property to implementing class, usually to a NativeSurface impleme...
static final float AUTOMAX_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale,...
Immutable Dimension Interface, consisting of it's read only components:
Immutable Point interface.
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.