PDA

View Full Version : JEDI-SDL, MacOS X and XCode Tutorial - a first pass



savage
18-11-2006, 05:53 PM
Hi all,
I have finally managed to iron out all the bugs involved putting together an XCode 2.4.x compatible project template that works with JEDI-SDL and FreePascal on MacOS X. A big thank-you goes out to Jonas Maebe for pointing me in the right direction. Ok the basic instructions are as follows...

-= START TUTORIAL =-

1. Need 1 cup of MacOS X

2. An installation of XCode 2.4 which ships with Tiger, but can the latest version can be downloaded by registering here - http://developer.apple.com/tools/download/ . Note the current version of 2.4.1 and weighs in at 924MB, so I hope you have broadband. This will give you a DMG ( Disk Image ) that will self mount. Follow the installation instructions.

3. Download and install the SDL disk image for MacOS X from - http://www.libsdl.org/release/SDL-1.2.11.dmg. Once this disk image has mounted you will find yourself in a folder with a Readme.txt a SDL.framework directory and a few other files.
To Install SDL:
Copy the SDL.framework to /Library/Frameworks
You can do the same thing for SDL_image, SDL_mixer, SDL_ttf and SDL_net.
/Library/Frameworks/ is the location for all private frameworks.
The standard OS frameworks are located in...
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks

4. Download and install FreePascal for MacOS X from - http://wiki.lazarus.freepascal.org/index.php/Lazarus_Snapshots_Downloads I downloaded a 2.1.1 snapshot about a week ago, but note that this branch is under heavy development so is not considered stable. You can try using the more stable 2.0.4 release, but I cannot vouch for that. Again this should give you a *.dmg files that will mount instelf and in this case launch an installation. Follow the instructions and you should have a working FreePascal compiler for MasOS X at the end of it.

5. If the installation above went well you should now have some FreePascal project templates located at...
/Library/Application Support/Apple/Developer Tools/Project Templates/Pascal/
under which will be "FPC Standard Tool" and "FPC Carbon Application" project templates. Now download the JEDI-SDL Disk Image from
http://www.pascalgamedevelopment.com/jedi-sdl/files/JEDI-SDLv1.0.dmg
Unzip the archived "FPC JEDI-SDL 2D Cocoa" and "FPC JEDI-SDL 3D Cocoa" folder at the same level as the previous FPC project templates.

6. Now start up XCode. Select "File->New Project". A New Project wizard should appear listing all the project templates available. Scroll down the list until you get to "Pascal". Under this node you should see the 2 FPC Project Templates and the JEDI-SDL 2D project template. Select "FPC JEDI-SDL 2D Cocoa" and click "Next". Now enter a Project Name and Directory. Note : If the directory does not exist, it will be created. When you happy click finish the newly created project will be opened and ready for editing within XCode.

7. Click the "Build and Go" icon and the compilation process will begin. Once completed ( it's a bit slower that Delphi ), you should see the JEDI-SDL logo ( thanks Jason ) bouncing around a native MacOS X window.

8. Read the Readme.txt file found within the JEDI-SDLv1.0.dmg file for hints on hacking these generated project to get your games working.

-= END TUTORIAL =-

This is the simplest way to get JEDI-SDL and XCode working together. A more indepth tutorial of how to create the project from scratch would include a lot of arcane magic and work arounds which Jonas has already had the misfortune of experiencing, hence why project templates are provided as a starting point when using XCode.

Any feedback or corrections welcome.

VilleK
18-11-2006, 08:13 PM
Thank you very much for this tutorial. I don't have a Mac yet, but this is exactly the information I will need when I get one and want to port my projects.

dmantione
18-11-2006, 09:00 PM
Hmm... Do you have plans to put this on a website? That would be one more article for the Free Pascal articles collection. :wink:

savage
18-11-2006, 09:48 PM
Hmm... Do you have plans to put this on a website? That would be one more article for the Free Pascal articles collection. :wink:

Yes, after receiving all feedback I plan to add it to the FPC Wiki, include it in the JEDI-SDL v1.0 release documentation and it will also be available from the JEDI-SDL website along with all the templates that I or others create.

I tested the new templating system by porting KiCHY's old Oxygene game that uses the sdlsprite.pas ( Sprite Engine ), and the only source code change I had to make was to remove the *fullscreen* parameter when the window is created. Everything else just compiled and ran once I had added the various bits to the project.
Here is a screen-shot...
http://www.pascalgamedevelopment.com/jedi-sdl/images/OxygeneMacOSX.png

WILL
18-11-2006, 11:23 PM
Really nice work Dom! ;)

Hey since we have the Article Editor back up, why don't you make this into an article? Been a long time since we added a new one to the site.

BTW, I don't recall the version of OXEGEN that I saw looking exactly like that. Maybe I just forgot, but is that version different at all from the version included in JEDI-SDL 0.5's examples?

savage
20-11-2006, 07:07 PM
Ok OpenGL is now also working. It turns out the path for Darwin was not set correctly. Once that was sorted out the Nehe 8 OpenGL demo ran without any problems...

http://www.pascalgamedevelopment.com/jedi-sdl/images/Nehe8MacOSX.png</img> ('http://www.pascalgamedevelopment.com/jedi-sdl/images/Nehe8MacOSX.png')

The 3D template project is now available from http://www.pascalgamedevelopment.com/jedi-sdl/files/FPC%20JEDI-SDL%203D.zip.

I will check-in the changes into CVS for gl, glu etc later this evening.

savage
02-12-2006, 09:02 PM
If you re-read the installation instructions you'll see that it now points to a MacOS X disk image, which contains a ReadMe.txt files with instructions on how to get everything working.

I think that will be all for this v1.0 release of JEDI-SDL. I am sure there are many areas that it can be improved but we can do that in the next release.