From cab8f6f62fc9703f4340c9522a1a2b7ef13cb8b6 Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Thu, 27 Mar 2003 23:01:14 +0000 Subject: [PATCH] New Window class, and major changes to Display --- src/java/org/lwjgl/Window.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/java/org/lwjgl/Window.java b/src/java/org/lwjgl/Window.java index 9a93c618..3c1a743a 100644 --- a/src/java/org/lwjgl/Window.java +++ b/src/java/org/lwjgl/Window.java @@ -27,7 +27,7 @@ public abstract class Window { } /** Whether we have a window already */ - private static boolean created; + private static Window currentWindow; /** The window's native data structure. On Win32 this is an HWND. */ private int handle; @@ -76,7 +76,7 @@ public abstract class Window { * @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) + if (currentWindow != null) throw new RuntimeException("Only one LWJGL window may be instantiated at any one time."); this.title = title; this.x = x; @@ -84,7 +84,7 @@ public abstract class Window { this.width = width; this.height = height; - created = true; + currentWindow = this; } /** @@ -168,7 +168,7 @@ public abstract class Window { * Destroy the window. */ public final void destroy() { - created = false; + currentWindow = null; nDestroy(); } @@ -184,6 +184,13 @@ public abstract class Window { return handle; } + /** + * @return true if a window has been created + */ + public static boolean isCreated() { + return currentWindow != null; + } + /** * 'Tick' the window. This must be called at least once per video frame * to handle window close requests, moves, paints, etc.