Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dooskington

Pages: [1]
1
General / Re: Load resources in app bundle
« on: September 20, 2015, 10:48:38 pm »
What about the solution provided in the official tutorial?
Quote
Header & source files: the project comes with a basic example in main.cpp and the helper function std::string resourcePath(void); in ResourcePath.hpp and ResourcePath.mm. The purpose of this function, as illustrated in the provided example, is to provide a convenient way to access the Resources folder of your application bundle.
Please note that this function only works on Mac OS X. If you are planning to make your application work on other operating systems, you should implement your own version of this function on the operating systems in question.

I didn't see that, now I feel stupid.

However I'm not using XCode. Where would I get that ResourcePath.hpp file?

2
General / Re: Load resources in app bundle
« on: September 20, 2015, 09:13:37 pm »
I figured it out. What a pain.

Remember to build your project with the CoreFoundation framework and to include "CoreFoundation/CoreFoundation.h".
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
    char path[512];
    if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8*)path, 512))
    {
        // error!
    }
    CFRelease(resourcesURL);
    strncat(path, "/geometos.ttf", 512); // The final path
 

I know that this is a Mac OSX specific solution, only when developing .app bundles, but there should be some sort of reference to this in the SFML docs. I'm not talking about an explanation, because there is enough documentation through Apple, but this would have been a lot easier for me to figure out it the tutorials told me "When developing a .app bundle, the working directory will have to be determined pragmatically.", and then a link to the App Bundle Reference.

3
General / Load resources in app bundle
« on: September 20, 2015, 08:05:38 pm »
I compile and bundle my SFML application into a .app, and then I run the app by typing open Orbs.app.
What I cannot figure out, however, is the working directory so that I can load a font. I copy a font to the Resources folder of the app during compilation, but the app can't find it. I thought that the default working directory of an SFML app was the resources folder?

Here is my folder structure:

Orbs.app
    Contents
        Mac OSX
            main (main binary)
        Resources
            SFML stuff
            geometos.ttf
            icon.icns
    info.plist

I want to be able to load the geometos.ttf font, but font.loadFromFile("geometos.ttf") cannot find the font. What do I have to do?

4
General / Re: Building SFML game with makefile issue
« on: September 19, 2015, 03:06:28 am »
I got it all working great. I will post it here for further reference, if anybody runs into the same issue:
There are probably some tweaks that could be done, and it will have to be modified for another project, but for the most part, the basics are there. It will compile Main.o with SFML, then link the object files to make a binary, then construct an app bundle.

CC = clang++
C_FLAGS = -Wall
SRC_PATH = src/
TARGET_PATH = bin/
INCLUDE_PATH = include/
FRAMEWORK_PATH = frameworks/
FRAMEWORKS = -framework sfml-system -framework sfml-graphics -framework sfml-window -framework sfml-audio
TARGET = Collector
APP_NAME = Collector

all: build_app package_app

build_app: $(TARGET_PATH)Main.o
        $(CC) -o $(TARGET_PATH)$(TARGET) $(TARGET_PATH)Main.o -F$(FRAMEWORK_PATH) $(FRAMEWORKS)

$(TARGET_PATH)Main.o: $(SRC_PATH)Main.cpp
        $(CC) -c $(SRC_PATH)Main.cpp -o $(TARGET_PATH)Main.o -I$(INCLUDE_PATH)

package_app:
        mkdir -p "bin/$(APP_NAME).app/Contents/MacOS"
        mkdir -p "bin/$(APP_NAME).app/Contents/Resources"
        cp -R "frameworks/" "bin/$(APP_NAME).app/Contents/Resources"
        cp src/info.plist "bin/$(APP_NAME).app/Contents"
        cp ./bin/Collector "bin/$(APP_NAME).app/Contents/MacOS/$(APP_NAME)"
        open bin/Collector.app

clean:
        rm -f $(TARGET_PATH)$(TARGET) $(TARGET_PATH)*.o
        rm -rf bin/$(APP_NAME).app/

 

5
General / Re: Building SFML game with makefile issue
« on: September 18, 2015, 05:34:20 pm »
btw, i'm new in sfml (and also in every animation through programming), so i wanna ask, can C++ use with SFML?

Yes. SFML is a C++ library.

6
General / Re: Building SFML game with makefile issue
« on: September 18, 2015, 03:32:07 pm »
I see...

I'm new to OSX development. I'm used to just doing g++ and getting a .exe file. I've never used CMake before, or made a .app. I'm trying to reduce my dependencies, and I hate xcode. I'll try to figure out how to bundle an .app from a makefile then.

Thank you!

7
General / Building SFML game with makefile issue
« on: September 18, 2015, 01:09:46 am »
I'm having somewhat of an issue with building my SFML project. I am on Mac OSX.

It is building and running just fine, but only if I have the lib folder under /usr/local/lib. I don't want this dependency. I want to just be able to run the program on its own, referencing the lib folder that it builds from. Here is my makefile:

CC = clang++
C_FLAGS = -Wall
INCLUDE_PATH = include/
LIB_PATH = lib/
LIBS = -lsfml-system -lsfml-graphics -lsfml-window -lsfml-audio

all: collector

collector: Main.o
        $(CC) -o collector Main.o -L$(LIB_PATH) $(LIBS)

Main.o: Main.cpp
        $(CC) -c Main.cpp -o Main.o -I$(INCLUDE_PATH)

clean:
        rm -f collector *.o
 

With this makefile, it compiles with the includes in my project folders include/ directory, and the libs in my project folders lib/ directory. However, when it comes to running, it will only run if, like I said before, I have the lib folder in /usr/local/. If it is not there, I get this error:

dyld: Library not loaded: @rpath/libsfml-system.2.3.dylib

How do I fix this? I do not want to use the Frameworks, so please don't point me to those.

Also, I understand that SFML requires some external dependencies that I have placed in Library/Frameworks. Is there any way to move those into my project directory for building as well? I just want to have all SFML files tied to my project, hands down.

Pages: [1]