Skip to content

Commit e5a9d5e

Browse files
committed
2 parents 42b3fca + 11bcfb5 commit e5a9d5e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

renderer/application.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A
2323
#include <iostream>
2424
#include <fstream>
2525
#include <string.h>
26+
#ifdef __APPLE__
27+
#include <unistd.h>
28+
#endif
2629

2730
#include <strutils.h>
2831
#include <common_platform.h>
@@ -50,8 +53,17 @@ CApplication::CApplication(int argc, char** argv)
5053

5154
bool CApplication::OpenWindow(size_t iWidth, size_t iHeight, bool bFullscreen, bool bResizeable)
5255
{
53-
if (!glfwInit())
54-
{
56+
#ifdef __APPLE__
57+
// On macOS, glfwInit() can change the current directory.
58+
// See http://www.glfw.org/docs/latest/group__init.html
59+
char *cwd = getcwd(0, 0);
60+
int ret = glfwInit();
61+
chdir(cwd);
62+
free(cwd);
63+
#else
64+
int ret = glfwInit();
65+
#endif
66+
if (!ret) {
5567
printf("glfwInit failed\n");
5668
exit(1);
5769
}

0 commit comments

Comments
 (0)