Renamed chdir option, added OS X menu bar option.

Some command-line programs want to render to hidden windows without any
visible UI.  This option makes this possible on OS X.
This commit is contained in:
Camilla Berglund 2013-01-24 19:45:21 +01:00
parent 6abb8e4c86
commit 8c766b57e7
4 changed files with 18 additions and 7 deletions

View File

@ -15,7 +15,8 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
if (APPLE)
option(GLFW_CD_RESOURCES "Make glfwInit chdir to Contents/Resources" ON)
option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON)
option(GLFW_USE_MENUBAR "Populate the menu bar on first window creation" ON)
else()
option(GLFW_USE_EGL "Use EGL for context creation" OFF)
endif()
@ -288,8 +289,12 @@ if (_GLFW_COCOA AND _GLFW_NSGL)
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
if (GLFW_CD_RESOURCES)
set(_GLFW_CD_RESOURCES 1)
if (GLFW_USE_MENUBAR)
set(_GLFW_USE_MENUBAR 1)
endif()
if (GLFW_USE_CHDIR)
set(_GLFW_USE_CHDIR 1)
endif()
# Universal build

View File

@ -34,7 +34,7 @@
// Change to our application bundle's resources directory, if present
//========================================================================
#if defined(_GLFW_CD_RESOURCES)
#if defined(_GLFW_USE_CHDIR)
static void changeToResourcesDirectory(void)
{
@ -70,7 +70,7 @@ static void changeToResourcesDirectory(void)
chdir(resourcesPath);
}
#endif /* _GLFW_CD_RESOURCES */
#endif /* _GLFW_USE_CHDIR */
//////////////////////////////////////////////////////////////////////////
@ -94,7 +94,7 @@ int _glfwPlatformInit(void)
return GL_FALSE;
}
#if defined(_GLFW_CD_RESOURCES)
#if defined(_GLFW_USE_CHDIR)
changeToResourcesDirectory();
#endif

View File

@ -581,6 +581,8 @@ static NSString* findAppName(void)
// doesn't seem like a good thing to require of GLFW's clients.
//========================================================================
#if defined(_GLFW_USE_MENUBAR)
static void createMenuBar(void)
{
NSString* appName = findAppName();
@ -640,6 +642,8 @@ static void createMenuBar(void)
[NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu];
}
#endif /* _GLFW_USE_MENUBAR */
//========================================================================
// Initialize the Cocoa Application Kit
@ -653,10 +657,12 @@ static GLboolean initializeAppKit(void)
// Implicitly create shared NSApplication instance
[GLFWApplication sharedApplication];
#if defined(_GLFW_USE_MENUBAR)
// Menu bar setup must go between sharedApplication above and
// finishLaunching below, in order to properly emulate the behavior
// of NSApplicationMain
createMenuBar();
#endif
[NSApp finishLaunching];

View File

@ -65,7 +65,7 @@
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT
// Define this to 1 if glfwInit should change the current directory
#cmakedefine _GLFW_CD_RESOURCES
#cmakedefine _GLFW_USE_CHDIR
// Define this to 1 if using OpenGL as the client library
#cmakedefine _GLFW_USE_OPENGL