diff --git a/examples/boing.c b/examples/boing.c index c060e4fb..ef33737d 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -606,7 +606,7 @@ int main( void ) glfwPollEvents(); /* Check if we are still running */ - running = !glfwGetKey( window, GLFW_KEY_ESC ); + running = glfwIsWindow(window) && !glfwGetKey( window, GLFW_KEY_ESC ); } while( running ); diff --git a/include/GL/glfw.h b/include/GL/glfw.h index 1f2bb8ad..4647b7bf 100644 --- a/include/GL/glfw.h +++ b/include/GL/glfw.h @@ -391,6 +391,7 @@ GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode); GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode); GLFWAPI void glfwOpenWindowHint(int target, int hint); GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window); +GLFWAPI int glfwIsWindow(GLFWwindow window); GLFWAPI void glfwCloseWindow(GLFWwindow window); GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title); GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height); diff --git a/lib/window.c b/lib/window.c index 1363ffa9..5383e29f 100644 --- a/lib/window.c +++ b/lib/window.c @@ -565,7 +565,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window) { - if (_glfwLibrary.currentWindow == window) + if (!_glfwInitialized || _glfwLibrary.currentWindow == window) return; _glfwPlatformMakeWindowCurrent(window); @@ -573,6 +573,19 @@ GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window) } +//======================================================================== +// Returns GL_TRUE if the specified window handle is an actual window +//======================================================================== + +GLFWAPI int glfwIsWindow(GLFWwindow window) +{ + if (!_glfwInitialized) + return; + + return window == _glfwLibrary.window; +} + + //======================================================================== // Set hints for opening the window //========================================================================