PDA

View Full Version : Loading and saving files



PollyPocket4eva
01-09-2009, 11:49 AM
Hi,
I'm working on a program that lets the user load a .obj file, manipulate it and then save it. I am working in Xcode on OS X and building the windowing side of things in GLUT so that I can use C/C++ rather than objective-c and cocoa interfacing.

Right now, the name and path to the .obj load and save files are hardcoded into the program, but I want to make it possible for the user to specify these.

Can anyone suggest a way I can do this given that I am using GLUT, etc.?
THANKS

todayman
01-09-2009, 05:09 PM
I don't think that GLUT has the ability to display an open dialog on its own. You would have to find another library that provides that, or write it yourself.

With that said, I believe that you could use objective-c code from C++ if you give the file a .mm extension. I know you can call C++ from objective-c. You could use the NSOpenPanel class, get the result, and convert it to a c string. Of course, by doing this you lose portability.

nicolasbol
02-12-2009, 10:09 PM
Be careful when using GLUT with macOS X, there is a very annoying bug that makes deployment difficult:

After you initialize the openGL context via "glutCreateWindow", the local path is translated to "/", which make for example, shaders extremely difficult to load.

The work around is to use "getcwd" from "unistd.h"