From 2fbd948a678a2ddceb70902bb68e3c5f8b98ddcb Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 29 Mar 2015 13:46:21 +0200 Subject: [PATCH] Fixed initialization failing on headless systems. Fixes #482. --- README.md | 2 ++ src/init.c | 7 ------- src/monitor.c | 4 ++++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d2f3eb14..0b29155e 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ GLFW bundles a number of dependencies in the `deps/` directory. ## Changelog + - Bugfix: Initialization failed on headless systems + ## Contact diff --git a/src/init.c b/src/init.c index 265c2d85..a72a73df 100644 --- a/src/init.c +++ b/src/init.c @@ -129,13 +129,6 @@ GLFWAPI int glfwInit(void) } _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount); - if (!_glfw.monitorCount) - { - _glfwInputError(GLFW_PLATFORM_ERROR, "No monitors found"); - _glfwPlatformTerminate(); - return GL_FALSE; - } - _glfwInitialized = GL_TRUE; // Not all window hints have zero as their default value diff --git a/src/monitor.c b/src/monitor.c index 71fa8ed2..9a155bd7 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -305,6 +305,10 @@ GLFWAPI GLFWmonitor** glfwGetMonitors(int* count) GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (!_glfw.monitorCount) + return NULL; + return (GLFWmonitor*) _glfw.monitors[0]; }