Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

playerWANG

OpenGL OpenGL and Mac OS X (Carbon\Xcode) crashing

This topic is 5176 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m a veteran DirectX\Win32 programmer but very much a n00b with Macs and OpenGL, period. But recently I dove into this strange new world and compiled a rotating texture mapped cube demo. It runs fine when I Build\Run but when I run it by itself (click on the executable outside the compiler) it crashes. Can anybody explain what I''m not doing?

Share this post


Link to post
Share on other sites
Advertisement
Realized I didn''t give any specifics. I''m loading a TGA file externally, meaning it''s not encoded into the program. And I''m using the NeHe Lesson 6, MacOS version that I''ve converted for Carbon.

Share this post


Link to post
Share on other sites
Sounds like your working directory is different whether you start it from the IDE or by hand.
You could try to use an absolute path to load the texture to test this.

Regards,
Jan

EDIT: I should think before writing

[edited by - jeickmann on June 11, 2004 2:23:18 PM]

Share this post


Link to post
Share on other sites
If your tga is included in the bundle then there is a cocoa function getPathforResource in the NSBundle class that would give u the correct path for the resource.

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSBundle.html#//apple_ref/occ/cl/NSBundle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Unfortunately the FAQ at idevgames.com which would answer this is down, but you could try createmacgames.org for a more exhaustive answer...

The simplest response is that you need to use either the Carbon or the Cocoa API calls to set the current working directory to the parent of the app (or the "Resources" folder of the .app bundle)

Running from Project Builder/XCode, the current working directory is automatically set to the "build" directory of the project.

The default working directory is "/"; I''ve no idea why...

This is from memory, but it should perfrom the directory switch under Carbon (a lot longer than the Cocoa variant, which is two lines...):

CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL( CFBundleGetMainBundleURL());
char resourcePath[ 4096 ];
CFURLGetFileSystemRepresentation( resourceURL, TRUE, resourcePath, 4096 );
chdir( resourcePath );
CFRelease( resourceURL );

Share this post


Link to post
Share on other sites
I have noticed this myself when using xcode. Directories can get screwed up on the project sometimes. When I create a project on my desktop, then later move it to a source folder in another directory, it won''t run, and sometimes won''t even compile. If you know how, try compiling it from the terminal manually, that usually works. Otherwise try fiddling with settings in xcode to make the build different, that can effect the problem you are having.

--------------------------------------------------------
Life would be so much easier if we could just get the source code.

Share this post


Link to post
Share on other sites
Thanks a lot guys! Always assumed the working directory would the same as the folder the executable is in (like Windows is). I''ll try to work from that angle...

Does anybody have a good recommendation for a book for MacOS? Carbon, specificially? All I have found is ''Carbon Programming'', which is kind of vanilla and too choppy for my reading.

Share this post


Link to post
Share on other sites
Hi, I have coded on the Mac quite a bit. The path issue is simple use this format "../dir/dir/filename" You have to remember you are using a Unix file system. Windows hides this I think from you. Also if you are moving from windows to OSX you will have to byte swap all your data that is not char(byte) so int, short, ect... all need to be byte swapped. So .tga files will need to have the width, height short swapped. Just to let you know heads up..

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!