|
From: <ka...@us...> - 2011-07-13 22:15:41
|
Revision: 3586
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3586&view=rev
Author: kappa1
Date: 2011-07-13 22:15:35 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Implement Resizing Display API for OS X
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -93,6 +93,12 @@
* unlike GL, where it is typically at the bottom of the display.
*/
private static int y = -1;
+
+ /** the width of the Display window */
+ private static int width = 0;
+
+ /** the height of the Display window */
+ private static int height = 0;
/** Title of the window (never null) */
private static String title = "Game";
@@ -109,6 +115,10 @@
private static boolean window_created;
private static boolean parent_resized;
+
+ private static boolean window_resized;
+
+ private static boolean window_resizable;
/** Initial Background Color of Display */
private static float r, g, b;
@@ -295,6 +305,9 @@
DisplayMode mode = getEffectiveMode();
display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
window_created = true;
+
+ width = Display.getDisplayMode().getWidth();
+ height = Display.getDisplayMode().getHeight();
setTitle(title);
initControls();
@@ -661,6 +674,13 @@
throw new RuntimeException(e);
}
}
+
+ window_resized = !isFullscreen() && parent == null && display_impl.wasResized();
+
+ if ( window_resized ) {
+ width = display_impl.getWidth();
+ height = display_impl.getHeight();
+ }
if ( parent_resized ) {
reshape();
@@ -1257,14 +1277,17 @@
* false to disable resizing on the Display window.
*/
public static void setResizable(boolean resizable) {
-
+ window_resizable = resizable;
+ if ( isCreated() ) {
+ display_impl.setResizable(resizable);
+ }
}
/**
* @return true if the Display window is resizable.
*/
public static boolean isResizable() {
- return false;
+ return window_resizable;
}
/**
@@ -1274,7 +1297,7 @@
* This will return false if running in fullscreen or with Display.setParent(Canvas parent)
*/
public static boolean wasResized() {
- return false;
+ return window_resized;
}
/**
@@ -1287,7 +1310,16 @@
* This value will be updated after a call to Display.update().
*/
public static int getWidth() {
- return 0;
+
+ if (Display.isFullscreen()) {
+ return Display.getDisplayMode().getWidth();
+ }
+
+ if (parent != null) {
+ return parent.getWidth();
+ }
+
+ return width;
}
/**
@@ -1300,6 +1332,15 @@
* This value will be updated after a call to Display.update().
*/
public static int getHeight() {
- return 0;
+
+ if (Display.isFullscreen()) {
+ return Display.getDisplayMode().getHeight();
+ }
+
+ if (parent != null) {
+ return parent.getHeight();
+ }
+
+ return height;
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -169,13 +169,8 @@
void setResizable(boolean resizable);
/**
- * @return true if the Display window is resizable.
+ * @return true if the Display window has been resized since this method was last called.
*/
- boolean isResizable();
-
- /**
- * @return true if the Display window has been resized.
- */
boolean wasResized();
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -1361,10 +1361,6 @@
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
return false;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -47,6 +47,7 @@
private int width;
private int height;
private boolean context_update;
+ private boolean resized;
MacOSXCanvasListener(Canvas canvas) {
this.canvas = canvas;
@@ -102,6 +103,7 @@
public void componentResized(ComponentEvent e) {
setUpdate();
+ resized = true;
}
public void componentMoved(ComponentEvent e) {
@@ -111,4 +113,13 @@
public void hierarchyChanged(HierarchyEvent e) {
setUpdate();
}
+
+ public boolean wasResized() {
+ if (resized) {
+ resized = false;
+ return true;
+ }
+
+ return false;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -497,11 +497,11 @@
}
public int getWidth() {
- return Display.getDisplayMode().getWidth();
+ return frame.getWidth();
}
public int getHeight() {
- return Display.getDisplayMode().getHeight();
+ return frame.getHeight();
}
public boolean isInsideWindow() {
@@ -509,15 +509,11 @@
}
public void setResizable(boolean resizable) {
-
+ frame.setResizable(resizable);
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
- return false;
+ return canvas_listener.wasResized();
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -68,7 +68,7 @@
private boolean should_release_cursor;
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
- setResizable(false);
+ setResizable(Display.isResizable());
addWindowListener(this);
addComponentListener(this);
canvas = new MacOSXGLCanvas();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -945,10 +945,6 @@
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|