From: <eli...@us...> - 2008-04-07 19:41:01
|
Revision: 2989 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2989&view=rev Author: elias_naur Date: 2008-04-07 12:40:53 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Added fullscreen switching to DisplayParentTest Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 19:31:23 UTC (rev 2988) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 19:40:53 UTC (rev 2989) @@ -79,19 +79,26 @@ Display.create(); float angle = 0f; - int current_height = 0; - int current_width = 0; while (isVisible()) { angle += 1.0f; - GL11.glViewport(0, 0, display_parent.getWidth(), display_parent.getHeight()); + int width; + int height; + if (!Display.isFullscreen()) { + width = display_parent.getWidth(); + height = display_parent.getHeight(); + } else { + width = Display.getDisplayMode().getWidth(); + height = Display.getDisplayMode().getHeight(); + } + GL11.glViewport(0, 0, width, height); GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight()); + GLU.gluOrtho2D(0.0f, (float) width, 0.0f, (float) height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); - GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f); + GL11.glTranslatef(width / 2.0f, height / 2.0f, 0.0f); GL11.glRotatef(2*angle, 0f, 0f, -1.0f); GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f); GL11.glPopMatrix(); @@ -107,6 +114,9 @@ if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { Mouse.setGrabbed(!Mouse.isGrabbed()); } + if(Keyboard.getEventKey() == Keyboard.KEY_F && Keyboard.getEventKeyState()) { + Display.setFullscreen(!Display.isFullscreen()); + } } /* while (Mouse.next()) { System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-06-08 09:30:27
|
Revision: 3102 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3102&view=rev Author: matzon Date: 2008-06-08 02:30:24 -0700 (Sun, 08 Jun 2008) Log Message: ----------- made windowClosing work by using a flag dont render if width or height < 1 Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-06-07 06:58:53 UTC (rev 3101) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-06-08 09:30:24 UTC (rev 3102) @@ -34,6 +34,8 @@ import java.awt.Canvas; import java.awt.Frame; import java.awt.GridLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import org.lwjgl.LWJGLException; import org.lwjgl.input.Keyboard; @@ -51,6 +53,7 @@ * $Id$ */ public class DisplayParentTest extends Frame { + boolean killswitch = false; public DisplayParentTest() throws LWJGLException { setTitle("LWJGL Display Parent Test"); setSize(640, 320); @@ -59,12 +62,11 @@ display_parent.setFocusable(true); display_parent.setIgnoreRepaint(true); add(display_parent); -/* addWindowListener(new WindowAdapter() { + addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - Display.destroy(); - dispose(); + killswitch = true; } - });*/ + }); setResizable(true); setVisible(true); Display.setParent(display_parent); @@ -72,7 +74,7 @@ Display.create(); float angle = 0f; - while (isVisible()) { + while (isVisible() && !killswitch) { angle += 1.0f; int width; int height; @@ -83,6 +85,11 @@ width = Display.getDisplayMode().getWidth(); height = Display.getDisplayMode().getHeight(); } + + if(width < 1 || height < 1) { + continue; + } + GL11.glViewport(0, 0, width, height); GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); @@ -115,7 +122,8 @@ System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY()); }*/ } - System.exit(0); + Display.destroy(); + dispose(); } public static void main(String[] args) throws LWJGLException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |