Thursday, December 27, 2007

Setting Up SDL with Visual C++ 2008 Express

Microsoft recently released Visual Studio Express. I wanted to see if my SDL setup instructions for Visual C++ 2005 Express (PDF) worked with Visual C++ 2008 Express so I installed Visual C++ 2008 Express and went through my instructions. The good news is Microsoft did not make a lot of changes in Visual C++ 2008 Express so most of the instructions still apply. There are two differences.

Visual C++ 2008 Express Contains the Win32 SDK

Unlike Visual C++ 2005 Express, Visual C++ 2008 Express ships with the Windows Platform SDK, also known as the Win32 SDK. Visual C++ 2008 Express's Win32 SDK support means you don't have to install the SDK separately, and you don't have to modify any files to get Win32 support.
 
If you're running Visual C++ 2008 Express, you can skip over the Installing the Windows Platform SDK, Updating the Visual C++ Properties File, and Updating the Application Wizard's Settings File sections in my instructions.

The Path to the Win32 SDK is Slightly Different

In the section Telling Visual C++ Where to Find Your SDL Headers and Libraries, I said the path to the Win32 SDK was the following path:

C:\Program Files\Microsoft Platform SDK

If you install Visual C++ 2008 Express, you'll find the Win32 SDK at the following path:

C:\Program Files\Microsoft SDKs\Windows\v6.0A

The v6.0A is the Win32 SDK version. If you're reading this in the future, the version number may change.

Wednesday, December 26, 2007

I've Installed Xcode 3

I installed Mac OS X 10.5 and Xcode 3 last night so I can now answer Xcode 3 questions. As I spend more time with the new Xcode Tools, I will take note of changes Apple made in Xcode 3 and write about them here.

Tuesday, December 11, 2007

Changing SDL's Working Directory on Mac OS X

The Mac OS X version of SDL sets the working directory to the directory containing the application bundle. This default behavior makes loading images and sounds more difficult because the images and sounds most likely reside in the application bundle's Resources folder. What would be nice would be to set the working directory to the Resources folder. How do you do this?

You change the working directory by modifying the method -setupWorkingDirectory: in the file SDLMain.m. You'll want to change the code in SDLMain.m in SDL's Xcode templates so your changes take effect for any new SDL projects you create. Just to be safe, you should comment out the original code or save a copy of it so you can go back to the original if things go wrong. Enter the following code in the -setupWorkingDirectory: method:


NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
[[NSFileManager defaultManager]
changeCurrentDirectoryPath
:resourcePath];


Thanks to Keith Bauer, aka OneSadCookie, for the source code to change the working directory.

Thursday, December 6, 2007

New Article: Playing Audio Files with QTKit

I have a new article on my website that explains how to load and play audio files using the QTKit framework. It should be especially helpful to any Cocoa developer who wants to loop an audio file because information on looping was hard to find in Apple's QTKit documentation.

Monday, October 29, 2007

I Don't Have Leopard Yet

Because I don't have Leopard yet, I don't have Xcode 3 so I can't answer your Xcode 3 questions. You can still ask them if you want, if you don't mind the response "I don't know". Apple has an Xcode mailing list where you can ask Xcode 3 questions as well as questions on other Apple developer tools like Interface Builder.

I will post on the blog when I get Leopard, also known as Mac OS X 10.5.

Thursday, October 11, 2007

New Article: Mac Game Programming Roadmap

I have a new article available that provides an overview of the technologies to learn to write Mac games. The article was motivated by a discussion that has been brewing on Apple's game development mailing list for several list. The discussion revolved around Apple's lack of support for games, and one complaint was that Apple did not have a game library like DirectX. Without a game library getting started with Mac game development can be difficult because he or she may not know where to begin. My article helps them know where to begin. If you're new to Mac game development, check out the article.

Monday, September 10, 2007

Changing the Application Name for an Xcode Project

Note: I got about 95% finished with this post when I realized it should be on the Xcode Tools Tips page. Because I was almost finished, I decided to also post it on the blog.

When you create an Xcode project, Xcode uses the project name as the title of whatever it builds. If you create an Xcode application project named MyProject, Xcode will create an application named MyProject when you build the project.

Suppose you're working on your application for a few weeks when you discover the perfect name for your application. You change the name of your project from MyProject to PerfectName, clean your project, and rebuild it. You expect to find an application named PerfectName in your build folder, but the application is still called MyProject. How do you get Xcode to build the project so the application name is PerfectName?

The answer is to modify the Product Name build setting, which you can find in the Packaging build settings collection. Product Name is the name of what Xcode builds, such as an application, a framework, or a library. Xcode initially uses the project name as the product name so when you look at the Product Name build setting, it will most likely be blank. Change the value of the Product Name to what you want, which would be PerfectName in this ongoing example.

When you change the Product Name build setting, you'll want to change it for the target, not a single build configuration. Changing the Product Name build setting for the target makes sure the change takes effect for all build configurations.

Monday, August 20, 2007

Setting up Visual C++ on Windows Vista

I have instructions on setting up Visual C++ 2005 Express for SDL and OpenGL on my OpenGL 2D book site. I based those instructions on what I had to do to set up Visual C++ on my brother's computer running Windows XP. When I used the instructions to set up Visual C++ on my Windows Vista virtual machine, a major problem occurred. Visual C++ crashed every time I tried to add an existing file to a project. The crashes occurred because I hadn't installed the necessary service packs.

There are two service packs you must install for Visual C++ to work with Vista. The first is Visual C++ 2005 Express Service Pack 1. The second is Visual Studio 2005 Service Pack 1 Update for Windows Vista. Both of these service packs can be downloaded at Microsoft's developer site.

Friday, August 17, 2007

Moving a Subversion Repository to a New Computer

I recently got one of the new iMacs, and I had to move my local Subversion repository to the new Mac. Getting the repository to the new Mac was a little tricky. Most of the Subversion tutorials on the Internet deal with creating a repository from scratch so I figured an article on moving a Subversion repository to a new computer would help people.

Moving the Repository

Moving a repository to a new computer requires three steps.
  1. Dump the repository's contents to a file.
  2. Create a repository on the new computer.
  3. Load the repository with the contents of the dumped file's contents.
Run the command svnadmin dump to dump the contents of a repository to a text file. Navigate to the directory above the repository, and run svndadmin dump.

svnadmin dump RepositoryName > DumpFile

Running svnadmin dump like I just did will write the contents of your repository to a file called DumpFile. Ideally you would dump the repository contents before you get your new computer and copy the dump file to your new computer. But I was able to copy my repository folder to the new computer and run svnadmin dump on the new computer.

After creating the dump file, run the command svnadmin create to create a new repository. Navigate to where you want the repository to reside and enter the following command:

svnadmin create RepositoryName

Now it's time to fill the newly created repository with the contents of the dump file. Run the command svnadmin load to fill the repository.

svnadmin load RepositoryName < DumpFile

Now you've managed to copy the repository over to the new computer.

Changing the Repository's Path

After recreating my old repository, I opened an Xcode project that was in the repository to see if the version control information was appearing in Xcode. The only information that was appearing was the files' local revision numbers. There was no information on previous versions of the project's files.

The cause of the problem was the repository path on the new computer did not match the path on the old computer. I needed to tell the files in the repository the new path to the repository.

The svn switch command accomplished this task. To tell the files the new repository path, move to the directory where the project's files reside and run the svn switch command using the --relocate option. When using the --relocate option, you first supply the old repository path, then the new path.

svn switch --relocate /Path/On/Old/Computer /Path/On/New/Computer

After running svn switch, all the version control information began to appear in Xcode.

Tuesday, July 31, 2007

SDL 1.2.12

The latest version of SDL, 1.2.12, is available to download from the SDL website. Anyone using Mac OS X and supporting joysticks in their game should download the update because it fixes a joystick calibration bug. When starting a game, SDL would record joystick axis events when the joystick was not moved, causing movement in the game with no joystick movement. The only way to stop the unwanted movement was to move the joystick up, down, left, and right. The 1.2.12 update eliminates the unwanted movement, making joysticks work the way you would expect on Mac OS X.