|
From: Caspian Rychlik-P. <ci...@us...> - 2003-03-27 22:46:29
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory sc8-pr-cvs1:/tmp/cvs-serv16223/src/java/org/lwjgl Modified Files: Window.java Log Message: New Window class, and major changes to Display Index: Window.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Window.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Window.java 27 Mar 2003 22:32:48 -0000 1.1 +++ Window.java 27 Mar 2003 22:46:25 -0000 1.2 @@ -15,8 +15,7 @@ * cannot be changed * - the window may be closeable by the user or operating system, and may be minimized * by the user or operating system - * - the operating system may or may not allow more than one window to be constructed - * at any one time. There is no guarantee that all windows can be visible at once. + * - only one window may ever be open at once * - the operating system may or may not be able to do fullscreen or windowed windows. * * @author foo @@ -26,6 +25,9 @@ static { System.loadLibrary(Sys.getLibraryName()); } + + /** Whether we have a window already */ + private static boolean created; /** The window's native data structure. On Win32 this is an HWND. */ private int handle; @@ -63,18 +65,26 @@ * * In this abstract base class, no actual window peer is constructed. This should be * done in specialised derived classes. + * + * Only one Window can be constructed at a time; to create another Window you must + * first destroy() the first window. * * @param title The window's title * @param x, y, width, height The position and dimensions of the client area of * the window. The dimensions may be ignored if the window cannot be made non- * fullscreen. The position may be ignored in either case. + * @throws RuntimeException if you attempt to create more than one window at the same time */ protected Window(String title, int x, int y, int width, int height) { + if (created) + throw new RuntimeException("Only one LWJGL window may be instantiated at any one time."); this.title = title; this.x = x; this.y = y; this.width = width; this.height = height; + + created = true; } /** @@ -157,7 +167,15 @@ /** * Destroy the window. */ - public final native void destroy(); + public final void destroy() { + created = false; + nDestroy(); + } + + /** + * Natively destroy the window + */ + private native void nDestroy(); /** * @return the native window handle |