Skip to content

Instantly share code, notes, and snippets.

@justinbowes
Last active December 16, 2015 20:19
Show Gist options
  • Save justinbowes/5491222 to your computer and use it in GitHub Desktop.
Save justinbowes/5491222 to your computer and use it in GitHub Desktop.
Making pighead10's SFML Ludum Dare entry, "You are the Minimalist", run in OSX.
// Call to implicitly-deleted copy constructor
Game.cpp:16 --------------------
-sf::RenderTexture Game::gameOutput = sf::RenderTexture();
+sf::RenderTexture Game::gameOutput;
main.cpp:3 ---------------------
#ifdef __APPLE__
#include <cstdio>
#include <sys/syslimits.h>
#include <CoreFoundation/CoreFoundation.h>
#define MAXPATHLEN PATH_MAX
#endif
// Need to copy media/ to Resources directory in app bundle
// App needs to cd into Resources in order for relative paths to work
// This code stolen from GLFW by elmindreda et al.
static void changeToResourcesDirectory(void)
{
char resourcesPath[MAXPATHLEN];
CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle)
return;
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
{
CFRelease(last);
CFRelease(resourcesURL);
return;
}
CFRelease(last);
if (!CFURLGetFileSystemRepresentation(resourcesURL,
true,
(UInt8*) resourcesPath,
MAXPATHLEN))
{
CFRelease(resourcesURL);
return;
}
CFRelease(resourcesURL);
chdir(resourcesPath);
}
int main(){
changeToResourcesDirectory();
Game::start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment