29package com.jogamp.opengl.test.junit.newt.mm;
31import java.io.IOException;
33import com.jogamp.opengl.GLCapabilities;
34import com.jogamp.opengl.GLProfile;
36import org.junit.AfterClass;
37import org.junit.Assert;
38import org.junit.BeforeClass;
40import org.junit.FixMethodOrder;
41import org.junit.runners.MethodSorters;
43import com.jogamp.newt.Display;
44import com.jogamp.newt.MonitorDevice;
45import com.jogamp.newt.NewtFactory;
46import com.jogamp.newt.Screen;
47import com.jogamp.newt.Window;
48import com.jogamp.newt.MonitorMode;
49import com.jogamp.newt.opengl.GLWindow;
50import com.jogamp.newt.util.MonitorModeUtil;
51import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
52import com.jogamp.opengl.test.junit.util.MiscUtils;
53import com.jogamp.opengl.test.junit.util.NewtTestUtil;
54import com.jogamp.opengl.test.junit.util.UITestCase;
58import com.jogamp.nativewindow.util.Dimension;
59import com.jogamp.nativewindow.util.DimensionImmutable;
60import com.jogamp.nativewindow.util.Rectangle;
73@FixMethodOrder(MethodSorters.NAME_ASCENDING)
76 static int width, height;
78 static long waitTimeShort = 2000;
79 static long duration = 4000;
81 static int mm_width = 800;
82 static int mm_height = 600;
86 setResetXRandRIfX11AfterClass();
94 Thread.sleep(waitTimeShort);
97 static Window createWindow(
final Screen screen,
final GLCapabilities caps,
final String name,
final int x,
final int y,
final int width,
final int height) {
98 Assert.assertNotNull(caps);
106 Assert.assertNotNull(window);
111 static void destroyWindow(
final Window window)
throws InterruptedException {
120 Thread.sleep(waitTimeShort);
123 Assert.assertNotNull(caps);
125 Assert.assertNotNull(display);
127 Assert.assertNotNull(screen);
128 final Window window0 = createWindow(screen, caps,
"win0", 0, 0, width, height);
129 Assert.assertNotNull(window0);
135 System.err.println(
"Test.0: Window bounds : "+window0WindowBounds+
" [wu] within "+screen.
getViewportInWindowUnits()+
" [wu]");
136 System.err.println(
"Test.0: Window size : "+window0SurfaceSize+
" [pixels]");
141 Assert.assertTrue(allMonitorModes.size()>0);
142 if(allMonitorModes.size()==1) {
144 System.err.println(
"Your platform has no MonitorMode change support (all), sorry");
145 destroyWindow(window0);
150 Assert.assertTrue(monitorModes.size()>0);
151 if(monitorModes.size()==1) {
153 System.err.println(
"Your platform has no MonitorMode change support (monitor), sorry");
154 destroyWindow(window0);
157 Assert.assertTrue(allMonitorModes.containsAll(monitorModes));
160 Assert.assertNotNull(mmSet0);
162 Assert.assertNotNull(mmOrig);
163 System.err.println(
"[0] orig : "+mmOrig);
164 System.err.println(
"[0] current: "+mmSet0);
165 Assert.assertEquals(mmSet0, mmOrig);
169 Assert.assertNotNull(monitorModes);
170 Assert.assertTrue(monitorModes.size()>0);
172 Assert.assertNotNull(monitorModes);
173 Assert.assertTrue(monitorModes.size()>0);
175 Assert.assertNotNull(monitorModes);
176 Assert.assertTrue(monitorModes.size()>0);
178 Assert.assertNotNull(monitorModes);
179 Assert.assertTrue(monitorModes.size()>0);
182 Assert.assertNotNull(monitorModes);
183 Assert.assertTrue(monitorModes.size()>0);
188 System.err.println(
"[1] set current: "+mm);
192 final boolean mmCurrentEquals = mmQueriedCurrent.
equals(mmCachedCurrent);
193 System.err.println(
"[1] changeOK : "+smOk);
194 System.err.println(
"[1] has current cached : "+mmCachedCurrent);
195 System.err.println(
"[1] has current queried : "+mmQueriedCurrent+
", equal "+mmCurrentEquals);
196 window0WindowBounds = window0.
getBounds();
198 System.err.println(
"Test.1: Window bounds : "+window0WindowBounds+
" [wu] within "+screen.
getViewportInWindowUnits()+
" [wu]");
199 System.err.println(
"Test.1: Window size : "+window0SurfaceSize+
" [pixels]");
204 Assert.assertEquals(mm, mmCachedCurrent);
205 Assert.assertNotSame(mmOrig, mmCachedCurrent);
207 Assert.assertTrue(smOk);
210 Thread.sleep(duration);
215 Assert.assertEquals(
true,window0.
isVisible());
218 destroyWindow(window0);
220 Assert.assertEquals(
false,window0.
isVisible());
226 Thread.sleep(waitTimeShort);
228 validateScreenModeReset(mmOrig, 0);
231 void validateScreenModeReset(
final MonitorMode mmOrig,
final int mmIdx) {
233 Assert.assertNotNull(display);
235 Assert.assertNotNull(screen);
250 public static void main(
final String args[])
throws IOException {
251 for(
int i=0; i<args.length; i++) {
252 if(args[i].equals(
"-time")) {
255 }
else if(args[i].equals(
"-mwidth")) {
258 }
else if(args[i].equals(
"-mheight")) {
263 System.err.println(
"Desired mode w/ resolution "+mm_width+
"x"+mm_height);
265 org.junit.runner.JUnitCore.
main(tstname);
abstract boolean isNativeValid()
Visual output device, i.e.
final boolean isModeChangedByUs()
Returns true</true> if the MonitorMode has been changed programmatic via this API only,...
final MonitorMode getCurrentMode()
Returns the cached current MonitorMode w/o native query.
abstract MonitorMode queryCurrentMode()
Returns the current MonitorMode resulting from a native query.
final RectangleImmutable getViewportInWindowUnits()
Returns the current rectangular portion of the rotated virtual Screen size in window units represente...
abstract boolean setCurrentMode(MonitorMode mode)
Set the current com.jogamp.newt.MonitorMode.
final List< MonitorMode > getSupportedModes()
Returns a list of immutable MonitorModes supported by this monitor.
final MonitorMode getOriginalMode()
Returns the immutable original com.jogamp.newt.MonitorMode, as used at NEWT initialization.
final RectangleImmutable getViewport()
Returns the current rectangular portion of the rotated virtual Screen size in pixel units represented...
Immutable MonitorMode Class, consisting of it's read only components:
final boolean equals(final Object obj)
Tests equality of two MonitorMode objects by evaluating equality of it's components:
final float getRefreshRate()
Returns the vertical refresh rate.
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 int addReference()
See Display#addReference().
abstract int removeReference()
See Display#removeReference().
abstract RectangleImmutable getViewport()
See Coordinate System.
abstract RectangleImmutable getViewportInWindowUnits()
See Coordinate System.
abstract List< MonitorMode > getMonitorModes()
Return a list of all MonitorModes for all MonitorDevices.
abstract boolean isNativeValid()
abstract List< MonitorDevice > getMonitorDevices()
Return a list of available MonitorDevices.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
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 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 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...
Convenient com.jogamp.newt.MonitorMode utility methods, filters etc.
static List< MonitorMode > filterByFlags(final List< MonitorMode > monitorModes, final int flags)
static List< MonitorMode > filterByResolution(final List< MonitorMode > monitorModes, final DimensionImmutable resolution)
static List< MonitorMode > getHighestAvailableBpp(final List< MonitorMode > monitorModes)
static List< MonitorMode > filterByRotation(final List< MonitorMode > monitorModes, final int rotation)
static List< MonitorMode > filterByRate(final List< MonitorMode > monitorModes, final float refreshRate)
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
static void releaseClass()
void testScreenModeChange01()
static void main(final String args[])
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)
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,...
Immutable Dimension Interface, consisting of it's read only components:
Specifying NEWT's Window functionality:
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.