Skip to content

Instantly share code, notes, and snippets.

@spaghetti-
Last active November 28, 2016 20:18
Show Gist options
  • Save spaghetti-/14f9ba97bb2761fc7a4f4a970ea98240 to your computer and use it in GitHub Desktop.
Save spaghetti-/14f9ba97bb2761fc7a4f4a970ea98240 to your computer and use it in GitHub Desktop.
diff -u src/init.c /tmp/src/init.c
--- src/init.c 2015-10-12 12:09:07.000000000 -0700
+++ /tmp/src/init.c 2016-11-28 12:14:40.418864596 -0800
@@ -128,12 +128,8 @@
return GL_FALSE;
}
- _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
_glfwInitialized = GL_TRUE;
- // Not all window hints have zero as their default value
- glfwDefaultWindowHints();
-
return GL_TRUE;
}
diff -u src/x11_init.c /tmp/src/x11_init.c
--- src/x11_init.c 2015-10-12 12:09:07.000000000 -0700
+++ /tmp/src/x11_init.c 2016-11-28 12:14:40.418864596 -0800
@@ -716,49 +716,11 @@
setlocale(LC_CTYPE, "");
#endif
- XInitThreads();
-
- _glfw.x11.display = XOpenDisplay(NULL);
- if (!_glfw.x11.display)
- {
- const char* display = getenv("DISPLAY");
- if (display)
- {
- _glfwInputError(GLFW_PLATFORM_ERROR,
- "X11: Failed to open display %s", display);
- }
- else
- {
- _glfwInputError(GLFW_PLATFORM_ERROR,
- "X11: The DISPLAY environment variable is missing");
- }
-
- return GL_FALSE;
- }
-
- _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
- _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
- _glfw.x11.context = XUniqueContext();
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "You are running in headless mode "
+ "Only functionality tested and that works is joystick input");
- if (!initExtensions())
- return GL_FALSE;
-
- _glfw.x11.cursor = createNULLCursor();
-
- if (XSupportsLocale())
- {
- XSetLocaleModifiers("");
-
- _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
- if (_glfw.x11.im)
- {
- if (!hasUsableInputMethodStyle())
- {
- XCloseIM(_glfw.x11.im);
- _glfw.x11.im = NULL;
- }
- }
- }
+ XInitThreads();
if (!_glfwInitContextAPI())
return GL_FALSE;
From e30160e9cde484e7e6f699d83d4f4e00678e3eed Mon Sep 17 00:00:00 2001
From: Alex <[email protected]>
Date: Thu, 27 Oct 2016 07:33:43 +0800
Subject: [PATCH] Remove all of the x11 gui init checks to allow joysticks in
headless
---
src/init.c | 4 ----
src/x11_init.c | 46 ++++------------------------------------------
2 files changed, 4 insertions(+), 46 deletions(-)
diff --git a/src/init.c b/src/init.c
index e0ebfad..fad749e 100644
--- a/src/init.c
+++ b/src/init.c
@@ -130,14 +130,10 @@ GLFWAPI int glfwInit(void)
return GLFW_FALSE;
}
- _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
_glfwInitialized = GLFW_TRUE;
_glfw.timerOffset = _glfwPlatformGetTimerValue();
- // Not all window hints have zero as their default value
- glfwDefaultWindowHints();
-
return GLFW_TRUE;
}
diff --git a/src/x11_init.c b/src/x11_init.c
index 012ab5b..eaa8319 100644
--- a/src/x11_init.c
+++ b/src/x11_init.c
@@ -732,49 +732,11 @@ int _glfwPlatformInit(void)
setlocale(LC_CTYPE, "");
#endif
- XInitThreads();
-
- _glfw.x11.display = XOpenDisplay(NULL);
- if (!_glfw.x11.display)
- {
- const char* display = getenv("DISPLAY");
- if (display)
- {
- _glfwInputError(GLFW_PLATFORM_ERROR,
- "X11: Failed to open display %s", display);
- }
- else
- {
- _glfwInputError(GLFW_PLATFORM_ERROR,
- "X11: The DISPLAY environment variable is missing");
- }
-
- return GLFW_FALSE;
- }
-
- _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
- _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
- _glfw.x11.context = XUniqueContext();
- _glfw.x11.helperWindowHandle = createHelperWindow();
- _glfw.x11.hiddenCursorHandle = createHiddenCursor();
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "You are running in headless mode "
+ "Only functionality tested and that works is joysticks");
- if (!initExtensions())
- return GLFW_FALSE;
-
- if (XSupportsLocale())
- {
- XSetLocaleModifiers("");
-
- _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
- if (_glfw.x11.im)
- {
- if (!hasUsableInputMethodStyle())
- {
- XCloseIM(_glfw.x11.im);
- _glfw.x11.im = NULL;
- }
- }
- }
+ XInitThreads();
if (!_glfwInitThreadLocalStoragePOSIX())
return GLFW_FALSE;
--
2.5.4 (Apple Git-61)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment