./Game
If I go
cd MyAMAZINGGame
./MySUPERgreatAMAZINGGame
It works fine,
but if I go
/MyAMAZINGGame/MySUPERgreatAMAZINGGame
It crashes
This is because It loads resources from the same directory it is run in, but I need to change that to load resources from the directory it is in...
How can I do this?
And also have it work multiplatform if possible (If thats not possible then ill just have to have the code change from the makefile or somthing but ill deal with that stuff later)
cd MyAMAZINGGame
./MySUPERgreatAMAZINGGame
It works fine,
but if I go
/MyAMAZINGGame/MySUPERgreatAMAZINGGame
It crashes
This is because It loads resources from the same directory it is run in, but I need to change that to load resources from the directory it is in...
How can I do this?
And also have it work multiplatform if possible (If thats not possible then ill just have to have the code change from the makefile or somthing but ill deal with that stuff later)
Sir, e^iπ + 1 = 0, hence God exists; reply!
What API/language?
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
just C with SDL and OpenGL.
Sir, e^iπ + 1 = 0, hence God exists; reply!
SDL sets the working directory to the directory containing your application bundle for you. You can change this behavior in SDL_main.m.
I cant find SDL_main, is that a file im supposed to create because I may have called it somthing else. Im linking my .o files together with gcc -o to get a unix application (Im guessing thats what it is, it runs from the terminal)
Sir, e^iπ + 1 = 0, hence God exists; reply!
no, that's a file you need to build a mac application with SDL.
I use SDL to make my window to put an OpenGL context in, and it all works multiplatform (Im hoping, very very hoping).
The kind is Unix Executable File, it was compiled from .c and .h file using gcc.
Im looking for a way to get kind of pwd, but inside my program so that I can load files from the resources directory in the same folder as the game.
The kind is Unix Executable File, it was compiled from .c and .h file using gcc.
Im looking for a way to get kind of pwd, but inside my program so that I can load files from the resources directory in the same folder as the game.
Sir, e^iπ + 1 = 0, hence God exists; reply!
If you are building this from the command line, then you're using using libSDLmain. That has the code that OneSadCookie is referring to. It doesn't do anything special if you aren't launching it from the finder anyway.
If the program is being launched from the command line, I don't know if it's possible to get the location of the executable. Usually people just put the data in a standard place like /usr/local/share.
If the program is being launched from the command line, I don't know if it's possible to get the location of the executable. Usually people just put the data in a standard place like /usr/local/share.
Assuming you have a POSIX-like system, you might try stripping the executable name off of argv[0] and changing the directory to that...
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
THATS IT, I knew there was a way!
Gives ./myGame when I do ./myGame, and give me myFolder/myGame when I double run it like that, sweet
.
Im not sure what libSDLmain.a is but its in /usr/local along with all my other SDL libraries so am I importing it when I do gcc `sdl-config --libs` ......
Gives ./myGame when I do ./myGame, and give me myFolder/myGame when I double run it like that, sweet
.Im not sure what libSDLmain.a is but its in /usr/local along with all my other SDL libraries so am I importing it when I do gcc `sdl-config --libs` ......
Sir, e^iπ + 1 = 0, hence God exists; reply!
Careful, it could be a relative path, it could be in the user's PATH, and it could contain any number of symbolic links. I have a library here: http://onesadcookie.com/svn/repos/ExecutablePath/ which can resolve that, but...
On Mac OS X it's much easier to use CFBundle or NSBundle to find your executable.
On Linux it's much easier to resolve the /proc/<pid>/exe symlink to find your executable, and
On Windows the CWD seems always to be the one containing your executable.
On Mac OS X it's much easier to use CFBundle or NSBundle to find your executable.
On Linux it's much easier to resolve the /proc/<pid>/exe symlink to find your executable, and
On Windows the CWD seems always to be the one containing your executable.
Thank you very much one sad cookie thats exactly what I have been looking for actually
.
.
Sir, e^iπ + 1 = 0, hence God exists; reply!
I just put
into my SDL_Main.m file.
some of those may be wrong, I haven't used any of those in a while.
Code:
chdir([[[[NSBundle mainBundle] resourcePath] absoluteString] UTF8String]);some of those may be wrong, I haven't used any of those in a while.
It's not magic, it's Ruby.
Thats pretty much what im doing in my other game that im writing but im hoping not to have to use any platform specific frameworks/libraries.
whats chdir?
I dont understand this SLD_main file, where is it? Is SDL_main.m the file that contains the in main(int argv, char *argc) { bit, (like the proc. that gets used when the application is started)? Because If it is then ive just called it myGame.c...
whats chdir?
I dont understand this SLD_main file, where is it? Is SDL_main.m the file that contains the in main(int argv, char *argc) { bit, (like the proc. that gets used when the application is started)? Because If it is then ive just called it myGame.c...
Sir, e^iπ + 1 = 0, hence God exists; reply!
man 2 chdir:
Quote:CHDIR(2) BSD System Calls Manual CHDIR(2)
NAME
chdir, fchdir -- change current working directory
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?

