Thursday, February 7, 2008

SDL File Loading When Running from Visual C++'s Debugger

I was testing some texture loading code on Visual C++ 2005 and 2008. The code compiled fine, but when I ran it from Visual C++'s debugger, it crashed every time. The code crashed because the program could not find my image file so it could not read the file and load the image. But the code ran file when I ran it from Windows Explorer. Why could my image file be found when I ran my program from Windows Explorer, but not from Visual C++'s debugger?

The reason was that Visual C++'s debugger uses a different working directory. Windows normally sets the working directory to the same directory as the executable file, which is where I had my image file. But Visual C++'s debugger sets the working directory to the directory containing the project file. Where is the project file? When you create a Visual C++ project, Visual C++ creates a folder that has the same name as the project name. Inside this folder is a second folder that has the same name as the project name. The project file resides in the second folder. The second folder is where the image file needed to be to debug my program. Moving my image file to the second folder fixed the crashing problem inside the Visual C++ debugger.

If you're using Visual C++ to write a game and you want to run the game inside the debugger, make sure your game's files are in the same directory as the project file.

Monday, February 4, 2008

XcodeTemplateFactory

Hog Bay Software recently released XcodeTemplateFactory, a utility that converts an Xcode project to a project template. I tried XcodeTemplateFactory, and it is an easy way to create Xcode project templates.

Building XcodeTemplateFactory

When you download XcodeTemplateFactory, you get an Xcode project file called XcodeTemplateFactory. Open the project in Xcode and build it to create the XcodeTemplateFactory app.

Creating a Project Template with XcodeTemplateFactory

To convert a project to a project template, run the XcodeTemplateFactory app that you built. Click the Choose button to open an Open File dialog box. Navigate to the folder containing your project and click the Open button. Enter a description of your project in the Project Description field. Make the description a good one. When you create a new Xcode project and select your template from the template list, your description is going to appear underneath the template list. Click the Generate Template button, and you've created an Xcode project template.