29package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
31import java.io.IOException;
32import java.net.URLConnection;
34import com.jogamp.common.util.IOUtil;
35import com.jogamp.newt.Display;
36import com.jogamp.newt.Display.PointerIcon;
37import com.jogamp.newt.NewtFactory;
38import com.jogamp.newt.Screen;
39import com.jogamp.newt.Window;
40import com.jogamp.newt.event.WindowEvent;
41import com.jogamp.newt.event.WindowAdapter;
42import com.jogamp.newt.opengl.GLWindow;
43import com.jogamp.newt.opengl.util.NEWTDemoListener;
44import com.jogamp.opengl.test.junit.util.UITestCase;
45import com.jogamp.opengl.test.junit.util.MiscUtils;
46import com.jogamp.opengl.test.junit.util.QuitAdapter;
47import com.jogamp.opengl.util.Animator;
48import com.jogamp.opengl.util.PNGPixelRect;
49import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
50import com.jogamp.opengl.test.junit.newt.parenting.NewtReparentingKeyAdapter;
51import com.jogamp.nativewindow.ScalableSurface;
52import com.jogamp.nativewindow.util.Dimension;
53import com.jogamp.nativewindow.util.DimensionImmutable;
54import com.jogamp.opengl.GLCapabilities;
55import com.jogamp.opengl.GLCapabilitiesImmutable;
56import com.jogamp.opengl.GLProfile;
58import jogamp.newt.driver.PNGIcon;
61import org.junit.FixMethodOrder;
62import org.junit.runners.MethodSorters;
72@FixMethodOrder(MethodSorters.NAME_ASCENDING)
77 static final int swapInterval = 1;
79 static long duration = 500;
80 static boolean opaque =
true;
89 System.err.println(
"requested: vsync "+swapInterval+
", "+caps);
115 setTitle(glWindow, caps);
120 setTitle(glWindow, caps);
124 final PointerIcon[] pointerIcons = {
null,
null,
null,
null,
null };
131 final IOUtil.ClassResources res =
new IOUtil.ClassResources(
new String[] {
"jogamp/newt/assets/cross-grey-alpha-16x16.png" }, glWindow.getClass().getClassLoader(),
null);
134 System.err.printf(
"Create PointerIcon #%02d: %s%n", idx, _pointerIcon.
toString());
135 }
catch (
final Exception e) {
138 pointerIcons[idx] = _pointerIcon;
143 final IOUtil.ClassResources res =
new IOUtil.ClassResources(
new String[] {
"jogamp/newt/assets/pointer-grey-alpha-16x24.png" }, glWindow.getClass().getClassLoader(),
null);
146 System.err.printf(
"Create PointerIcon #%02d: %s%n", idx, _pointerIcon.
toString());
147 }
catch (
final Exception e) {
150 pointerIcons[idx] = _pointerIcon;
155 final IOUtil.ClassResources res =
new IOUtil.ClassResources(
new String[] {
"arrow-red-alpha-64x64.png" }, glWindow.getClass().getClassLoader(),
null);
158 System.err.printf(
"Create PointerIcon #%02d: %s%n", idx, _pointerIcon.
toString());
159 }
catch (
final Exception e) {
162 pointerIcons[idx] = _pointerIcon;
167 final IOUtil.ClassResources res =
new IOUtil.ClassResources(
new String[] {
"arrow-blue-alpha-64x64.png" }, glWindow.getClass().getClassLoader(),
null);
170 System.err.printf(
"Create PointerIcon #%02d: %s%n", idx, _pointerIcon.
toString());
171 }
catch (
final Exception e) {
174 pointerIcons[idx] = _pointerIcon;
177 if( PNGIcon.isAvailable() ) {
179 final IOUtil.ClassResources res =
new IOUtil.ClassResources(
new String[] {
"jogamp-pointer-64x64.png" }, glWindow.getClass().getClassLoader(),
null);
181 final URLConnection urlConn = res.resolve(0);
183 System.err.printf(
"Create PointerIcon #%02d: %s%n", idx, image.
toString());
185 System.err.printf(
"Create PointerIcon #%02d: %s%n", idx, _pointerIcon.
toString());
186 }
catch (
final Exception e) {
189 pointerIcons[idx] = _pointerIcon;
198 animator.
add(glWindow);
209 System.err.println(
"HiDPI PixelScale: "+reqSurfacePixelScale[0]+
"x"+reqSurfacePixelScale[1]+
" (req) -> "+
210 valReqSurfacePixelScale[0]+
"x"+valReqSurfacePixelScale[1]+
" (val) -> "+
211 hasSurfacePixelScale1[0]+
"x"+hasSurfacePixelScale1[1]+
" (has)");
212 setTitle(glWindow, caps);
216 final long t0 = System.currentTimeMillis();
218 while(!quitAdapter.shouldQuit() && t1-t0<duration) {
220 t1 = System.currentTimeMillis();
233 runTestGL(caps,
false);
236 public static void main(
final String args[])
throws IOException {
238 for(
int i=0; i<args.length; i++) {
239 if(args[i].equals(
"-time")) {
242 }
else if(args[i].equals(
"-translucent")) {
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
abstract void createNative()
Manual trigger the native creation, if it is not done yet.
abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY)
Returns the newly created PointerIcon or null if not implemented on platform.
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract Display getDisplay()
NEWT Window events are provided for notification purposes ONLY.
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 addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
final float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.
final int getX()
Returns the current x position of this window, relative to it's parent.
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 float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
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 int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
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 setUndecorated(final boolean value)
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 int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
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 GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
void setValidateBuffers(final boolean v)
static void main(final String args[])
void runTestGL(final GLCapabilitiesImmutable caps, final boolean undecorated)
static long atol(final String str, final long def)
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.
final synchronized boolean stop()
Stops this animator.
static PNGPixelRect read(final InputStream in, final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, final boolean destIsGLOriented)
Reads a PNG image from the specified InputStream.
int getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
int getSurfaceHeight()
Returns the height of the client area excluding insets (window decorations) in pixel units.
Rectangle getBounds()
Returns a newly created Rectangle containing window origin, getX() & getY(), and size,...
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:
Native PointerIcon handle.
Specifying NEWT's Window functionality:
void setTitle(String title)
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.