I've encounter a roadblock in porting OpenGL applications to Mac OS X. The problem centers around the "current working directory". Normal unix applications inherit the current working directory from the parent not the application, e.g. a call to fopen() looks to the directory from which an application was started, not from the directory in which the application happens to be stored. In unix apps ported to OS X that contains no calls to OpenGL, the unix convention is followed; however, if you link to Apples OpenGL.framework and GLUT.framework and include code to initialize the gl window, the current working directory switches from the parent to the application directory. This means that an fopen() call that is looking for a data file in the directory from which an application is launched cannot find the data file if it searches for it after any call to a glut library function (e.g. glutInit()) because that call changes the current working directory to the application directory.
For example, If you have a unix/openGL app in /usr/local/bin (not uncommon place to put your own special app's) and launch the application from your own home directory to analyze data in stored in your directory, Whether the application finds the data is dependent on when a call to fopen () is made. If the data file is opened before you uinitialize the gl window, the current working directory is the parent and the data file is found. If the data file is opened after you initialize the gl window, the current working directory has changed to "/usr/local/bin" in this example and your data file is MIA. Now that is just wrong!
I've reported this anomally to Apples developers bug reporting site over a month ago and have received NOTHING in return, not even the confirmation that this is a known bug. Has anyone found this same problem and is there a workaround till something is fixed in the Apple GLUT framework.
P.S. the answer is not "use the glut libraries in XFree86 4.2 and XDarwin". That does work and there is no switching of directories, but unaccelerated openGL is so unbareably slow as to make it unacceptable even as a temporary fix.
signed
Fed up with slow bug eaters at Apple!
For example, If you have a unix/openGL app in /usr/local/bin (not uncommon place to put your own special app's) and launch the application from your own home directory to analyze data in stored in your directory, Whether the application finds the data is dependent on when a call to fopen () is made. If the data file is opened before you uinitialize the gl window, the current working directory is the parent and the data file is found. If the data file is opened after you initialize the gl window, the current working directory has changed to "/usr/local/bin" in this example and your data file is MIA. Now that is just wrong!
I've reported this anomally to Apples developers bug reporting site over a month ago and have received NOTHING in return, not even the confirmation that this is a known bug. Has anyone found this same problem and is there a workaround till something is fixed in the Apple GLUT framework.
P.S. the answer is not "use the glut libraries in XFree86 4.2 and XDarwin". That does work and there is no switching of directories, but unaccelerated openGL is so unbareably slow as to make it unacceptable even as a temporary fix.
signed
Fed up with slow bug eaters at Apple!