OpenGL GLUT Application Template

Filed under Apple + Programming + Tutorials + xcode on Thursday, 21 August, 2008 2:15 am

Here is a downloadable template to create an OpenGL GLUT Application (using an app bundle) for the people who haven’t figured out how to use Xcode 100% as yet.

There area Xcode templates freely available for SDL OpenGL projects but not for GLUT so I’m providing this one myself. I think I found this on a MacRumors thread so I cannot take credit for this but anyway, enjoy.

48AAFD8E-1EDA-4522-A24E-F1A50746E5D4.jpg

Brock

How To use Dynamic Libraries in Xcode 3.1 (using FMOD)

Filed under Apple on Thursday, 21 August, 2008 1:12 am

I am writing this article to help people running Xcode on Mac OS X get around the dreaded FMOD dynamic libary not found error from happening at runtime:

dyld: Library not loaded: @loader_path/../Frameworks/libfmodex.dylib
  Referenced from: /Users/brock/Game/Debug/mine.app/Contents/MacOS/mine
  Reason: image not found

So here we go, the first step is to install FMOD Ex Programmers API. You can download it here:
http://www.fmod.org/index.php/download

Once you have downloaded it, run the FMOD Installer.
Once installed, all FMOD resources should be located: 

/Developer/FMOD Programmers API/

The dynamic libraries that you will need to include with your application will be located in:

/Developer/FMOD Programmers API/api/lib/ 

You should drag the library you wish to use into your Xcode project’s Framework folder so that it looks like:

Picture 2.png

Once you have completed your FMOD coded application in Xcode, you will need to create a shell script that Xcode will automatically run upon completion of building your .app bundle.

If you are compiling a shell tool, which doesn’t encapsulate all the project’s code, this will still work, but you will need to modify the code below by removing the .app path stuff where appropriate.

In order to get rid of the dreaded dylib not found error, then you will need to run the otool command as well as creating a script for Xcode to run after everything is built. The otool command will tell you where your application is expecting to find the libraries and frameworks that it looks for at runtime.
So, type this:

otool -L /path/to/AppName.app/Contents/MacOS/AppName

which should produce something like:

./libfmodexp.dylib (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/GLUT.framework/Versions/A/GLUT (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/SDL.framework/Versions/A/SDL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenAL.framework/Versions/A/OpenAL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)

Notice the top line, this means that the application expects to find:
“./libfmodexp.dylib”. Which is our FMOD dylib file.
However this will not exist at runtime, so we have to get Xcode to copy this file into the app bundle as well as modify the binary to look in its new location:

So, in Xcode, right-click on your target and choose:

Add > New Build Phase > New Run Script Build Phase

Picture 3.png

You should see a new item under the target called “Run Script”:

Picture 4.png

Double-click the “Run Script” folder and paste in the following command:
WARNING! If you are copy pasting this be sure that the quotes “” don’t get converted to curly quotes. You will need to replace these.

mkdir “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks”
cp -f /Developer/FMOD Programmers API/api/lib/libfmodex.dylib “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libfmodex.dylib”

install_name_tool -change ./libfmodexp.dylib @loader_path/../Frameworks/libfmodex.dylib “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME”

Picture 6.png

You will need to modify this script according to your own setup.
Xcode will also inform you of any errors with your script in the Build Warning and Errors window when you build your project.

You should do a clean then do a build. After the build is complete Xcode will run the script.
Step by step what this script does it:

1) Creates a new directory called “Frameworks” inside the application’s bundle
2) Copies the “libfmodex.dylib” file from the FMOD developer folder to the /Frameworks directory that was just created.
3) And lastly the install_name_tool command will modify the application binary to look for the library in the new location.

Thanks for reading my little tutorial on this. This process was really not as straight forward as it ought to be so I wanted others to benefit from this (as well as myself should I ever forget how to do this!). Any questions or if you would like me to change anything please login and leave a comment.

If you liked this article and would like to download a copy for reference you can download it:

Download a zipped iWork Pages document              834AB2CD-A0EB-40EB-B650-DD5F73B2FEAE.jpg
Download Pages                                       Download PDF

Cheers
Brock

MobileMe Message to IE7 Users

Filed under Apple on Friday, 8 August, 2008 11:47 pm

I saw this in a review of MobileMe. Apparently if you try to use it in conjunction with Internet Explorer 7, Apple warns you not to use IE7. It’s quite amusing to see Apple using Microsoft’s tactics against themselves.

Get a better web browser.
Download Safari
Download Firefox

How Time Machine Saved My Bacon

Filed under Apple + Software on Thursday, 4 October, 2007 4:15 pm

TimeMachineDock

I write this post to you from my MacBook Pro, in its restored state as of last night when I finished writing an important university assignment. This is important because without Leopard’s Time Machine backup feature, I would have lost at least one or two full days getting my machine restored.

Presently, I am running a Developer’s release of Mac OS X Leopard (9A557 build) in a production environment. This is particularly dangerous because you don’t know if (or when) something is going to break. As I write this in Safari I remind myself to click ’save’ because I can’t write this again if Safari decides to crash. I paranoidly (is that even a word?) backup everything on my 250GB internal laptop’s drive. This is not bad at all, something which everyone should do. And we all know everyone does their backups frequently right?

(Click here for the full article…)

How to Restart the Mac OS X Menubar

Filed under Apple on Friday, 13 July, 2007 9:10 pm

 

Picture 2.png

Just a quick tip. If your menubar crashes in OS X it can be restarted by typing a simple command in the Terminal.

killall SystemUIServer

You can also restart the Dock by typing:

killall Dock

or the Finder by typing:

killall Finder

All these commands are case-sensitive.

Change File Permissions using Terminal in Mac OS X

Filed under Apple on Wednesday, 4 July, 2007 9:56 pm

Terminal

Changing file permissions on the Mac is something you need to know how to do if you want to create your own non-home directory only shares on the Mac. Leopard implements folder sharing similarly to the way SharePoints does. I find myself needing to change permissions regularly because certain programs like to change file permissions on their own. The Terminal is generally better for changing permissions because it is much faster and also because you have more control. Sometimes you may need to do this is the file permissions get messed up in Leopard’s File Sharing under System Preferences. 
Here’s how it works:

(Click here for the full article…)

Electronic Arts Coming to OS X

Filed under Apple + Gaming on Monday, 18 June, 2007 8:01 pm

electronic arts logo

Electronic Arts chief creative officer Bing Gordon at Apple’s latest Developer conference stated that EA would be moving some of their most appealing titles to the Mac coming available in the next few months. The first games to become available for Mac will include Command and Conquer 3, Battlefield 2142, Need for Speed Carbon, and Harry Potter and the Order of the Phoenix. This is certainly great news for Mac gamers and now it sounds like I should finally be able to decommission Boot Camp on my MacBook Pro’s hard drive. However there is one issue that was conveniently skipped over at the keynote.

Although these games are coming to the Mac they aren’t being ported, well not in the traditional sense anyway. TransGaming’s Cider which acts as an interpreter between the game’s original code and the Mac OS frameworks will be used as a wrapper to get the games to run under OS X. The problem lies in the fact that interpreting code uses much more resources rather than running pre-compiled code, which pretty much every game is.

If you have ever used Azureus, a java bittorrent client you will know that it is much slower than say Transmission. While Azureus does more than Transmission, it is significantly slower considering than all it really does is display text and download files. The same thing would in theory apply to gaming under Cider. Since most of these games already require all the hardware you can throw their way, it doesn’t sound like Mac gamers are getting a fair deal.

Worldwide the Mac platform accounts for roughly 5% of the installed base of PCs. However since most Mac users aren’t gamers, rather than designers, power users and technically challenged folk, etc. I can understand why EA would not go to the trouble of investing more money to properly port their games to Mac versions. The bright side is that EA may only be testing the waters with Cider and hopefully all new future releases from EA will be proper fully compiled Mac versions.

If the EA Cider titles run close to the performance of their Windows versions then I will probably run the Mac versions. In the end, this is only good news for Mac gaming.

How to Add (Java) Packages to Xcode

Filed under Apple + Programming on Wednesday, 18 April, 2007 12:53 pm

xcodejava

I have started writing Java programs at uni and i’m required to add a Java package called B102.jar to the compiler.
Well, the university doesn’t support anyting other than Windows so it was a pain trying to figure out how to use Xcode and use their ‘B102.jar’ package. Anyway to add a .jar package to Xcode for compilation, all you need to do is add your .jar package to:

/System/Library/Java/Extensions/

That’s it. Now when you type import B102.*; for example, it will compile correctly.

Safe Sleep Guide for Mac OS X

Filed under Apple on Tuesday, 17 April, 2007 7:11 pm

Sleeping cat :P

Safe Sleep is a kind of sleep mode similar to what Windows users have. It was integrated into the Mac OS X kernel a few years ago and can be enabled through the Terminal. Mac users use the sleep mode often, either letting their computers go into sleep mode after a preset time or manually sleeping the machine. Sleep is especially useful on portable Macs, such as the MacBook or MacBook Pro.

The problem with sleep mode on portable Macs is that is doesn’t always work right. A few times I’ve put my MacBook Pro to sleep and come back later only to find the fans spinning really fast because it didn’t go to sleep properly. It was very hot and I thought it might have damaged the hardware, luckily it was ok. Safe Sleep uses no power and so completely solves this problem because it powers off the computer rather than preserving the RAM state by using a low power state. It does take a little longer than normal sleep but it’s worth it in my opinion:

Pros and Cons
+ Preserves complete system state using NO POWER
+ Restore is faster than doing a cold boot
+ Your laptop won’t burst into flames from screaming fans whilst in a bag
- Takes longer to sleep than normal sleep mode

Safe Sleep mode in action on my MacBook Pro:

Enabling Safe sleep mode is relatively easy, however you need to take come caution, especially if you are using Secure Virtual Memory. Safe sleep doesn’t appear to work if you are using secure virtual memory, but you should take caution if you attempt to enable it.

Safe Sleep can only be enabled under Mac OS X 10.3 (Panther) or 10.4 (Tiger). You should make a copy of the instructions below or print them out, incase you have problems.

Step 1. Enable Safe Sleep
To enable safe sleep on your Mac, the Open Firmware needs execute some code at boot time.
Open the Terminal, enter each line while pressing enter at the end of each line:

sudo nvram nvramrc=’” /” select-dev
” msh” encode-string ” has-safe-sleep” property
unselect

sudo nvram “use-nvramrc?”=true

Restart the computer.

Step 2. Enable Hibernate Mode
To continue, you must have at least as much free disk space as RAM in your computer , plus 750MB.
Therefore if you have 2GB of RAM, you must have at least 2.75GB of free space on your hard disk.

To enable Safe Sleep, in the Terminal enter:

sudo pmset -a hibernatemode 3

This should create the file /var/vm/sleepimage.

If (and only if) you have secure virtual memory enabled, enter 7 (rather than 3) to disable encrypted
hibernation. Encrypted Safe Sleep does not yet work.

Now when your Mac enters sleep, it will now enter the regular Sleep mode first (consuming minimal power). But will
only enter Safe-Sleep if the battery is very low on power, or is unplugged.
To use Safe Sleep mode instead (which takes a bit longer to sleep and wake-up) enter in the Terminal:

sudo pmset -a hibernatemode 1

Enter 5 (rather than 1) with secure virtual memory.
To disable Safe Sleep:

sudo pmset -a hibernatemode 0

You do not need to restart to set the changes for hibernate mode.
Happy lappy sleeping :)

A big thanks to Andrew Escobar for providing the info

World of Warcraft Free Gold

Filed under Apple on Thursday, 1 February, 2007 3:42 pm

PoisonicIn other news, I couldn’t believe the other night. I was playing World of Warcraft and I managed to make 75g in under 1 minute. Yes you heard me! I wasn’t hacking or farming or selling something at the auction house. I made 75 Gold because of the incompetence of a level 67 Mage who shall remain nameless. It goes a little something like this (I am Poisonic):

Mage : Can anyone tell me how to become an enchanter?Poisonic : Yeah you need to find the trainer. Speak to a guard.Mage : kkMage : WTB [Strange Dust]Poisonic : I have someMage : I’ll give you 75s for 20 strange dustPoisonic : ok. meet me in Ironforge.Mage : kk

So I meet this guy, then I ask for more money, being the greedy sea urchin that I am and not surprisingly he yells at me and says no that’s all your getting. So I say OK and we proceed to do the trade.So I put in my 20 Strange dust and he puts in 75G. He typed in 75 Gold! Well you would not believe how god damn fast I pressed the trade button. Trade trade trade trade!!!!! So the deal got done and unbeknownst to him, he gave me 75 gold instead of 75 silver! He didnt even ask for it back so I was happy as pie and proceeded to auction house where I bought myself the best armour money can buy :)

Next Page »