mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Cleaned up bundle resource directory logic, clarified comment.
This commit is contained in:
parent
e23eed7e27
commit
7302f761d9
|
@ -313,6 +313,7 @@ version of GLFW.</p>
|
|||
<li>[Cocoa] Replaced <code>NSDate</code> time source with <code>mach_absolute_time</code></li>
|
||||
<li>[Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable</li>
|
||||
<li>[Cocoa] Bugfix: The OpenGL framework was not retrieved, making glfwGetProcAddress crash</li>
|
||||
<li>[Cocoa] Bugfix: <code>glfwInit</code> changed the current directory for unbundled executables</li>
|
||||
<li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li>
|
||||
<li>[X11] Added the POSIX <code>CLOCK_MONOTONIC</code> time source as the preferred method</li>
|
||||
<li>[X11] Added dependency on libm, where present</li>
|
||||
|
|
|
@ -72,6 +72,18 @@ NSString* GLFWNameKeys[] =
|
|||
};
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Change to our application bundle's resources directory, if present
|
||||
//========================================================================
|
||||
static void changeToResourcesDirectory(void)
|
||||
{
|
||||
char* resourcePath = [[[NSBundle mainBundle] resourcePath] UTF8String];
|
||||
|
||||
if (access(resourcePath, R_OK) == 0)
|
||||
chdir(resourcePath);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Try to figure out what the calling application is called
|
||||
//========================================================================
|
||||
|
@ -87,24 +99,18 @@ static NSString* findAppName(void)
|
|||
[name isKindOfClass:[NSString class]] &&
|
||||
![@"" isEqualToString:name])
|
||||
{
|
||||
_glfwLibrary.NS.bundled = GL_TRUE;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we're unbundled
|
||||
if (!_glfwLibrary.NS.unbundled)
|
||||
{
|
||||
// Could do this only if we discover we're unbundled, but it should
|
||||
// do no harm...
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
|
||||
// Having the app in front of the terminal window is also generally
|
||||
// handy. There is an NSApplication API to do this, but...
|
||||
SetFrontProcess(&psn);
|
||||
|
||||
_glfwLibrary.NS.unbundled = GL_TRUE;
|
||||
}
|
||||
// Having the app in front of the terminal window is also generally
|
||||
// handy. There is an NSApplication API to do this, but...
|
||||
SetFrontProcess(&psn);
|
||||
|
||||
char** progname = _NSGetProgname();
|
||||
if (progname && *progname)
|
||||
|
@ -210,16 +216,16 @@ int _glfwPlatformInit(void)
|
|||
return GL_FALSE;
|
||||
}
|
||||
|
||||
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
|
||||
|
||||
if (access([resourcePath cStringUsingEncoding:NSUTF8StringEncoding], R_OK) == 0)
|
||||
chdir([resourcePath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
|
||||
// Setting up menu bar must go exactly here else weirdness ensues
|
||||
// Setting up the menu bar must go between sharedApplication
|
||||
// above and finishLaunching below, in order to properly emulate the
|
||||
// behavior of NSApplicationMain
|
||||
setUpMenuBar();
|
||||
|
||||
[NSApp finishLaunching];
|
||||
|
||||
if (_glfwLibrary.NS.bundled)
|
||||
changeToResourcesDirectory();
|
||||
|
||||
_glfwPlatformSetTime(0.0);
|
||||
|
||||
_glfwLibrary.NS.desktopMode =
|
||||
|
|
|
@ -91,7 +91,7 @@ typedef struct _GLFWlibraryNS
|
|||
|
||||
// dlopen handle for dynamically loading OpenGL extension entry points
|
||||
void* OpenGLFramework;
|
||||
GLboolean unbundled;
|
||||
GLboolean bundled;
|
||||
id desktopMode;
|
||||
id delegate;
|
||||
id autoreleasePool;
|
||||
|
|
Loading…
Reference in New Issue
Block a user