From 29891baca2427483f96e6d1a8c3b13892ba5facc Mon Sep 17 00:00:00 2001 From: Rami Santina Date: Wed, 20 Oct 2010 16:26:45 +0300 Subject: Added Windows Impl for ScreenMode and rotation change; Windows Fullscreen Hint Added windows implemenation for screen mode change lifecycle and screen rotation screen modes. +++++++++++ Added getHighestAvailableRate() to Screen mode as a helper function which loops over the available rates of this screen mode and returns the highest available. Added toString impl to ScreenMode. +++++++++++ Unit Tests: TestScreenMode01NEWT,TestScreenMode02NEWT are modified adding the gears as GL event listeners. +++++++++++ Notes: 1- Screen modes with bits per pixel values not same as current are currently filtered out. 2- Since windows stores the Display settings differently you will see some duplicate values which the documentation says is usual. These modes are not filtered out in getScreenModes(). Keeping values same as provided from windows enum. 3- BitsPerPixel is currently natively read on windows only. --- .../test/junit/newt/TestScreenMode01NEWT.java | 78 ++++++++++------------ .../test/junit/newt/TestScreenMode02NEWT.java | 8 ++- 2 files changed, 41 insertions(+), 45 deletions(-) (limited to 'src/junit/com/jogamp') diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java index 5dbc56c7d..a3da32bd3 100644 --- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java @@ -29,8 +29,9 @@ package com.jogamp.test.junit.newt; import java.io.IOException; -import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; import org.junit.Assert; import org.junit.BeforeClass; @@ -41,13 +42,17 @@ import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.newt.impl.ScreenMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.test.junit.jogl.demos.gl2.gears.Gears; import com.jogamp.test.junit.util.UITestCase; public class TestScreenMode01NEWT extends UITestCase { + static GLProfile glp; static int width, height; - static int waitTimeShort = 1000; //1 sec - static int waitTimeLong = 6000; //6 sec + static int waitTimeShort = 4; //1 sec + static int waitTimeLong = 6; //6 sec + @BeforeClass @@ -55,34 +60,19 @@ public class TestScreenMode01NEWT extends UITestCase { NativeWindowFactory.initSingleton(true); width = 640; height = 480; + glp = GLProfile.getDefault(); } - static Window createWindow(Screen screen, Capabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { Assert.assertNotNull(caps); caps.setOnscreen(onscreen); - // Create native windowing resources .. X11/Win/OSX - // - Window window = NewtFactory.createWindow(screen, caps); + + boolean destroyWhenUnused = screen.getDestroyWhenUnused(); + GLWindow window = GLWindow.create(screen, caps); + window.addGLEventListener(new Gears()); Assert.assertNotNull(window); - window.setUndecorated(onscreen && undecorated); - window.setSize(width, height); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(destroyWhenUnused, window.getScreen().getDestroyWhenUnused()); window.setVisible(true); - Assert.assertEquals(true,window.isVisible()); - Assert.assertEquals(true,window.isNativeValid()); - - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // - caps = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); - Assert.assertNotNull(caps); - Assert.assertTrue(caps.getGreenBits()>5); - Assert.assertTrue(caps.getBlueBits()>5); - Assert.assertTrue(caps.getRedBits()>5); - Assert.assertEquals(caps.isOnscreen(),onscreen); - return window; } @@ -100,21 +90,21 @@ public class TestScreenMode01NEWT extends UITestCase { @Test public void testFullscreenChange01() throws InterruptedException { - Capabilities caps = new Capabilities(); + GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); Screen screen = NewtFactory.createScreen(display, 0); // screen 0 Assert.assertNotNull(screen); - Window window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - window.setFullscreen(true); + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + window.setFullscreen(true); Assert.assertEquals(true, window.isFullscreen()); - Thread.sleep(waitTimeShort); - + for(int state=0; state 4) + { + modeIndex = screenModes.length - 2; + } ScreenMode screenMode = screenModes[modeIndex]; Assert.assertNotNull(screenMode); -- cgit v1.2.3