<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>meandmark.com &#187; SDL</title>
	<atom:link href="http://meandmark.com/blog/category/sdl/feed/" rel="self" type="application/rss+xml" />
	<link>http://meandmark.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 16 Jan 2012 19:04:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Using SDL with Xcode 4</title>
		<link>http://meandmark.com/blog/2012/01/using-sdl-with-xcode-4/</link>
		<comments>http://meandmark.com/blog/2012/01/using-sdl-with-xcode-4/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 19:31:36 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[xcode 4]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=432</guid>
		<description><![CDATA[Apple changed the format for project templates in Xcode 4. The format change means the Xcode templates that ship with the Mac version of SDL don&#8217;t work in Xcode 4. If you have both Xcode 3 and 4 installed on your Mac, you can create a project that uses SDL in Xcode 3 and open [...]]]></description>
			<content:encoded><![CDATA[<p>Apple changed the format for project templates in Xcode 4. The format change means the Xcode templates that ship with the Mac version of SDL don&#8217;t work in Xcode 4. If you have both Xcode 3 and 4 installed on your Mac, you can create a project that uses SDL in Xcode 3 and open it in Xcode 4. But if you&#8217;re running Xcode 10.7 and don&#8217;t have Xcode 3 installed, you&#8217;re stuck with Xcode 4 and can&#8217;t use the SDL project templates. But you can use Xcode 4 to create SDL applications without too much hassle.</p>
<h3>Create a Cocoa Application Project</h3>
<p>When you create a project in Xcode, select the Cocoa Application project, as you can see in the following screenshot:</p>
<p><img src="http://meandmark.com/blog/wp-content/uploads/2012/01/Xcode4CocoaProjectStep1.png" border="0" alt="Xcode4CocoaProjectStep1" width="600" height="404" /></p>
<p>The Mac OS X version of SDL is written with Cocoa so a Cocoa application project is the closest template to the old SDL project templates. Click the Next button to move to the next step where you name the project.</p>
<p><img src="http://meandmark.com/blog/wp-content/uploads/2012/01/Xcode4CocoaProjectStep2.png" border="0" alt="Xcode4CocoaProjectStep2" width="600" height="404" /></p>
<p>Deselect the Create Document-Based Application, Use Core Data, and Use Automatic Reference Counting checkboxes. SDL games don&#8217;t use Core Data or Apple&#8217;s NSDocument class. Automatic Reference Counting is for Objective-C code, which most of you won&#8217;t use if you&#8217;re using SDL. If you want to unit test your game with OCUnit, select the Include Unit Tests checkbox. My <a href="http://meandmark.com/blog/2010/11/using-xcode-to-unit-test-sdl-games-written-in-c/">Using Xcode to Unit Test SDL Games Written in C++</a> post has detailed information on using OCUnit to unit test C++ code.</p>
<p>Click the Next button to move on to the final step of creating a project. Pick a location to save the project and click the Create button. If you want to place your project in a local git repository, select the checkbox to create the repository.</p>
<h3>Remove Unwanted Files from the Project</h3>
<p>Apple&#8217;s Cocoa application project template contains files that are not needed for SDL games. You can remove the xib file and source code files from the project: any files ending in .xib, .m, and .h. In Xcode 4.2 you would delete the following files: main.m, MainMenu.xib, AppDelegate.h, and AppDelegate.m. Select a file and choose Edit &gt; Delete to delete the file from the project. An alert opens. If you click the Delete button, Xcode deletes the file instead of moving it to the Trash. Clicking the Remove Reference button is the safer option. My <a href="http://meandmark.com/blog/2011/05/xcode-4-removing-files-from-a-project/">Xcode 4: Removing Files from a Project</a> post has additional information on removing files from a project.</p>
<h3>Add the SDL Framework to the Project</h3>
<p>Now it&#8217;s time to add the SDL framework to the project. Select the project file from the project navigator to open the project editor. Select your target from the left side of the project editor. Click the Summary button at the top of the editor to see a list of linked frameworks. Click the + button to add a framework. More information on adding frameworks is in my <a href="http://meandmark.com/blog/2011/03/xcode-4-adding-a-framework-to-your-project/">Xcode 4: Adding a Framework to Your Project</a> post. Click the + button to add any additional frameworks, such as OpenGL, SDL_image, and SDL_mixer.</p>
<h3>Add SDLMain to the Project</h3>
<p>The Mac version of SDL uses two files, SDLMain.m and SDLMain.h, that contain glue code for running SDL code on Mac OS X. The SDL project templates include these files, but in Xcode 4 you must add them to your project. Choose File &gt; Add Files to ProjectName to add the files. After adding the SDLMain files to the project, you can start coding.</p>
<h3>Add Search Paths</h3>
<p>When I tried to build a SDL project with Xcode 4, I got a build error saying that the file SDL.h was not found. The solution was to add the following search path to the Header Search Paths build setting:</p>
<p>/Library/Frameworks/SDL.framework/Headers</p>
<p>You may also need to add a search path to the Framework Search Paths build setting, but I didn&#8217;t need to add a path. You may also need to specify additional search paths if you use additional frameworks, such as SDL_image and SDL_mixer. My <a href="http://meandmark.com/blog/2011/03/xcode-4-accessing-build-settings/">Xcode 4: Accessing Build Settings</a> post has detailed information on accessing build settings in Xcode 4.</p>
<h3>Copy the SDL Framework to Your Application Bundle</h3>
<p>The SDL Xcode project templates copy the SDL framework to your application bundle. Copying the framework to the application bundle allows someone to play your SDL game without having SDL installed. If you want the SDL framework added to your application bundle, add a Copy Files build phase to your target and add the SDL framework to the build phase.</p>
<ol>
<li>Select the project file from the project navigator to open the project editor.</li>
<li>Select the target from the left side of the project editor.</li>
<li>Click the Build Phases button at the top of the editor.</li>
<li>Click the Add Build Phase button at the bottom of the editor.</li>
<li>Choose Add Copy Files from the menu.</li>
<li>Drag the SDL framework from the project navigator to the table in the Copy Files build phase.</li>
<li>Choose Frameworks from the Destination menu.</li>
</ol>
<p><img src="http://meandmark.com/blog/wp-content/uploads/2012/01/SDLCopyFilesBuildPhase.png" border="0" alt="SDLCopyFilesBuildPhase" width="600" height="163" /></p>
<p>If you have additional frameworks to copy to the application bundle, repeat Step 6 for those frameworks. Don&#8217;t copy Apple&#8217;s frameworks to the application bundle; every Mac has Apple&#8217;s frameworks installed. Only copy third-party frameworks, such as SDL_image and SDL_mixer.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2012/01/using-sdl-with-xcode-4/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>SDL OpenGL Typedef Redefinition Error on Mac OS X 10.7</title>
		<link>http://meandmark.com/blog/2011/11/sdl-opengl-typedef-redefinition-error-on-mac-os-x-10-7/</link>
		<comments>http://meandmark.com/blog/2011/11/sdl-opengl-typedef-redefinition-error-on-mac-os-x-10-7/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 19:00:28 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Mac Development]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=389</guid>
		<description><![CDATA[If you build a SDL OpenGL application for Mac OS X using SDL 1.2.14 (using the binary installer at the SDL site) and the Mac OS X 10.7 SDK, you can get the following error: typedef redefinition with different types ('unsigned int' vs 'void *') The SDL header file SDL_opengl.h and the OpenGL header file [...]]]></description>
			<content:encoded><![CDATA[<p>If you build a SDL OpenGL application for Mac OS X using SDL 1.2.14 (using the binary installer at the SDL site) and the Mac OS X 10.7 SDK, you can get the following error:</p>
<pre>typedef redefinition with different types ('unsigned int' vs 'void *')</pre>
<p>The SDL header file SDL_opengl.h and the OpenGL header file glext.h both define a data type GLhandleARB. SDL_opengl.h defines it as an unsigned integer. The Mac OS X 10.7 version of glext.h defines it as a void pointer. Defining GLhandleARB as different data types in different header files causes problems.</p>
<p>The SDL team fixed the problem in their <a href="http://hg.libsdl.org">Mercurial repository</a>. The fix is not too difficult to apply. In your SDL_opengl.h file, change the following line of code:</p>
<pre>typedef unsigned int GLhandleARB;</pre>
<p>To the following:</p>
<pre>#if defined(__APPLE__)    </pre>
<pre><span style="white-space: pre;">	</span>typedef void *GLhandleARB;</pre>
<pre>#else    </pre>
<pre><span style="white-space: pre;">	</span>typedef unsigned int GLhandleARB;</pre>
<pre>#endif</pre>
<p>The fix defines GLhandleARB as a void pointer on Mac OS X and an unsigned integer on other operating systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2011/11/sdl-opengl-typedef-redefinition-error-on-mac-os-x-10-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Xcode Project for SDL OpenGL Article</title>
		<link>http://meandmark.com/blog/2011/08/new-xcode-project-for-sdl-opengl-article/</link>
		<comments>http://meandmark.com/blog/2011/08/new-xcode-project-for-sdl-opengl-article/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 19:34:39 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=350</guid>
		<description><![CDATA[I added a link to the sidebar of my SDL OpenGL article that contains a version of the project updated for Xcode 4.1. The original project had several problems building on Xcode 4.1 that persisted after I modernized the project. The updated version of the project works on Xcode 4.1 and uses the Mac OS [...]]]></description>
			<content:encoded><![CDATA[<p>I added a link to the sidebar of my SDL OpenGL article that contains a version of the project updated for Xcode 4.1. The original project had several problems building on Xcode 4.1 that persisted after I modernized the project. The updated version of the project works on Xcode 4.1 and uses the Mac OS X 10.7 SDK. I have not tested the project on Xcode 4.0, but at a minimum, you must change the Base SDK to 10.6 to get the project to work on Xcode 4.0.</p>
<p>The original project is still there. I just added another version to make things easier for people using Xcode 4.1.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2011/08/new-xcode-project-for-sdl-opengl-article/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing Name of Xcode Project Doesn&#8217;t Change Name in Menu Bar</title>
		<link>http://meandmark.com/blog/2011/03/changing-name-of-xcode-project-doesnt-change-name-in-menu-bar/</link>
		<comments>http://meandmark.com/blog/2011/03/changing-name-of-xcode-project-doesnt-change-name-in-menu-bar/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 19:47:54 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=276</guid>
		<description><![CDATA[I recently changed the name of an Xcode SDL project. The change worked except for one problem. The menu bar showed the old project name as the application name. What was strange was the menus in the application menu (About App, Hide App, Quit App) showed the new project name. What was causing the menu [...]]]></description>
			<content:encoded><![CDATA[<p>I recently changed the name of an Xcode SDL project. The change worked except for one problem. The menu bar showed the old project name as the application name. What was strange was the menus in the application menu (About App, Hide App, Quit App) showed the new project name. What was causing the menu bar to show the old project name?</p>
<p>The culprit was the project&#8217;s InfoPlist.strings file. I noticed the keys CFBundleName, CFBundleShortVersionString, and CFBundleGetInfoString had the old project name. Changing these keys to the new project name, cleaning the project, and rebuilding the project fixed the problem. The menu bar now shows the new project name.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2011/03/changing-name-of-xcode-project-doesnt-change-name-in-menu-bar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Xcode to Unit Test SDL Games Written in C++</title>
		<link>http://meandmark.com/blog/2010/11/using-xcode-to-unit-test-sdl-games-written-in-c/</link>
		<comments>http://meandmark.com/blog/2010/11/using-xcode-to-unit-test-sdl-games-written-in-c/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 20:59:19 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=258</guid>
		<description><![CDATA[Suppose you&#8217;re using SDL to program a game. You&#8217;re writing the game in C++, and you want to write unit tests for your code. Your first instinct would be to use a C++ unit testing framework like googletest or UnitTest++. Your instinct would be correct on Linux and Windows, but the Mac version of SDL [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose you&#8217;re using SDL to program a game. You&#8217;re writing the game in C++, and you want to write unit tests for your code. Your first instinct would be to use a C++ unit testing framework like googletest or UnitTest++. Your instinct would be correct on Linux and Windows, but the Mac version of SDL uses Cocoa, which is an Objective-C framework. If you try to unit test your SDL C++ game on a Mac, you&#8217;re going to get hundreds of compiler errors related to the Cocoa framework because a C++ unit testing framework doesn&#8217;t understand Objective-C. How do you unit test your SDL game on a Mac?</p>
<p>Use Xcode&#8217;s built-in support for Objective-C unit testing. Add a Cocoa unit testing bundle target to your project. Add an Objective-C test case class to your project, making sure to add the test case class to the unit testing target, not the target for your SDL game. Give the test case file the extension .mm instead of .m. Giving the file the extension .mm tells Xcode to treat the test case file as an Objective-C++ file, which allows you to unit test your C++ code with OCUnit, the Objective-C unit testing framework that comes with Xcode.</p>
<p>Make sure your game&#8217;s C++ source files are members of the unit testing target you created. If you don&#8217;t add your game&#8217;s C++ files to the unit testing target, you will get linker errors when your unit tests access your game&#8217;s classes. Read my <a href="http://meandmark.com/blog/2010/11/googletest-xcode-tip/">googleTest Xcode Tip post</a> for instructions on adding your C++ files to the unit testing target.</p>
<p>Apple&#8217;s Xcode Unit Testing Guide, which is part of Apple&#8217;s Mac developer documentation, contains additional information on setting up Xcode for unit testing. Also, thanks to Chris Hanson for his answer to a question 5 years ago on one of Apple&#8217;s mailing lists. Without his answer I would have never known you could unit test C++ code with OCUnit.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2010/11/using-xcode-to-unit-test-sdl-games-written-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Troubleshooting PNG Loading with SDL_image</title>
		<link>http://meandmark.com/blog/2010/04/troubleshooting-png-loading-with-sdl_image/</link>
		<comments>http://meandmark.com/blog/2010/04/troubleshooting-png-loading-with-sdl_image/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 20:17:09 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[SDL_image]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=198</guid>
		<description><![CDATA[SDL_image is a library that simplifies loading image files for SDL games. One of the more popular image file formats for games is PNG, and SDL_image has support for PNG. On game development message boards, you&#8217;ll find many questions from people having trouble loading PNG files with SDL_image. This trouble has two common causes. Cause [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.libsdl.org/projects/SDL_image">SDL_image</a> is a library that simplifies loading image files for SDL games. One of the more popular image file formats for games is PNG, and SDL_image has support for PNG. On game development message boards, you&#8217;ll find many questions from people having trouble loading PNG files with SDL_image. This trouble has two common causes.</p>
<h2>Cause 1: PNG Files Not Found</h2>
<p>The most common cause of trouble of PNG file loading is the operating system being unable to find the file. Suppose you have the following SDL_image function call in your code to load an image:</p>
<p><code></p>
<pre>SDL_Surface* image;
image = IMG_Load_RW("background.png", 1);</pre>
<p></code></p>
<p>That code works only if the file <strong>background.png</strong> is in the current working directory. If the file isn&#8217;t in the current working directory, SDL_image won&#8217;t load it, and you have problems.</p>
<p>On Linux and Windows, the current working directory is the directory where the executable file is. Make sure your image files are in the same directory as the executable file.</p>
<p>On Mac OS X, SDL sets the working directory to the directory containing the application bundle. But your image files are in the Resources folder inside the application bundle. This means the code example to load <strong>background.png</strong> will not work on Mac OS X. The best solution is to change the working directory. My <a href="http://meandmark.com/blog/2009/12/sdl-tips-for-mac-os-x">SDL Tips for Mac OS X post</a> has instructions on changing the working directory.</p>
<h2>Cause 2: DLLs Not Found</h2>
<p>The second common cause of PNG loading problems affects only Windows programmers. For SDL code to run on Windows, Windows must be able to find the SDL DLLs. To find the DLLs, they must reside either in the same directory as the executable file or in the <strong>windows\system32</strong> directory.</p>
<p>To use SDL_image on Windows, you must add the SDL_image DLL to the same location as the SDL DLL. Most people remember to add the SDL_image DLL, but they discover PNG files will not load.</p>
<p>The reason the PNG files will not load is that loading PNG files with SDL_image on Windows requires the zlib and libpng DLLs as well as the SDL_image DLL. It&#8217;s an easy mistake to make, and the error message SDL_image returns isn&#8217;t very clear. The solution is to move the zlib and libpng DLLs to the same location as the SDL and SDL_image DLLs.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2010/04/troubleshooting-png-loading-with-sdl_image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SDL Tips for Mac OS X</title>
		<link>http://meandmark.com/blog/2009/12/sdl-tips-for-mac-os-x/</link>
		<comments>http://meandmark.com/blog/2009/12/sdl-tips-for-mac-os-x/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 05:30:32 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://www.meandmark.com/blog/files/sdl-tips-mac.html#unique-entry-id-1</guid>
		<description><![CDATA[SDL’s most compelling feature is its cross-platform compatibility. You can use the same source code to write a game for Linux, Mac OS X, Windows, and any other system SDL supports. When people write a game with SDL on Linux or Windows and try to build a Mac version of your game, they learn that [...]]]></description>
			<content:encoded><![CDATA[<p>SDL’s most compelling feature is its cross-platform compatibility. You can use the same source code to write a game for Linux, Mac OS X, Windows, and any other system SDL supports. When people write a game with SDL on Linux or Windows and try to build a Mac version of your game, they learn that Mac OS X has some subtle differences from Linux and Windows. The three tips in this post should help people create Mac versions of their SDL games.</p>
<p><strong>Use the Xcode Project Templates</strong></p>
<p>If you haven’t done so already, go to the <a rel="self" href="http://www.libsdl.org">SDL website</a> and download it. At the SDL download site, you will see both runtime and development libraries for Mac OS X. Download both libraries. The runtime libraries contain the SDL framework. The development libraries contain documentation and Xcode project templates.</p>
<p>The Xcode project templates do two nice things for you when you build the project. First, the templates create a proper Mac application bundle for you. Second, the templates copy the SDL framework to the application bundle. Including the SDL framework with your game lets people play your game without having to install SDL.</p>
<p><strong>Adding Files to the Game</strong></p>
<p>Games contain many external files, such as graphics, sound, and data files. Mac games store these files in the Resources folder inside the game’s application bundle. If you add graphics, sound, and data files to your project’s Resources folder, they will be copied to the application bundle’s Resources folder when you build your project.</p>
<p>Go to the Groups and Files list on the left side of Xcode’s project window. The top entry should be the name of your project. Click the disclosure triangle next to the project name to see a series of folders. Right-click the Resources folder and choose Add &gt; Existing Files. Select the files you want to add and click the Add button. </p>
<p>A second sheet will open. If you are adding individual files, click the Add button. If you’re adding a folder of files, click the Create Folder References for any added folders radio button before clicking the Add button. Creating a folder reference copies the folder to the Resources folder inside the application bundle when Xcode builds your project.</p>
<p><strong>Changing the Working Directory</strong></p>
<p>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 usually reside in the application bundle&#8217;s Resources folder. You can make file loading simpler by changing the working directory to the Resources folder.</p>
<p>Open the file SDLMain.m and modify the setupWorkingDirectory: method. The following code changes the working directory to the application bundle’s Resources folder:</p>
<p><code>NSString *resourcePath = [[NSBundle mainBundle] resourcePath];<br />[[NSFileManager defaultManager] changeCurrentDirectoryPath:resourcePath];</code></p>
<p>By changing the working directory to the application’s Resources folder, you should be able to use the same code to load files on Linux, Mac OS X, and Windows.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2009/12/sdl-tips-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>SDL File Loading When Running from Visual C++’s Debugger</title>
		<link>http://meandmark.com/blog/2008/02/sdl-file-loading-when-running-from-visual-cs-debugger/</link>
		<comments>http://meandmark.com/blog/2008/02/sdl-file-loading-when-running-from-visual-cs-debugger/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 06:55:00 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=69</guid>
		<description><![CDATA[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++&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>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++&#8217;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++&#8217;s debugger?</p>
<p>The reason was that Visual C++&#8217;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++&#8217;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.</p>
<p>If you&#8217;re using Visual C++ to write a game and you want to run the game inside the debugger, make sure your game&#8217;s files are in the same directory as the project file.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2008/02/sdl-file-loading-when-running-from-visual-cs-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up SDL with Visual C++ 2008 Express</title>
		<link>http://meandmark.com/blog/2007/12/setting-up-sdl-with-visual-c-2008-express/</link>
		<comments>http://meandmark.com/blog/2007/12/setting-up-sdl-with-visual-c-2008-express/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 18:15:00 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=58</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft recently released Visual Studio Express. I wanted to see if my <a href="http://www.meandmark.com/sdlvisualc.pdf">SDL setup instructions for Visual C++ 2005 Express</a> (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.</p>
<div>
<div></div>
<div><span style="font-weight: bold;">Visual C++ 2008 Express Contains the Win32 SDK</span></div>
<div></div>
<div></div>
<p>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&#8217;s Win32 SDK support means you don&#8217;t have to install the SDK separately, and you don&#8217;t have to modify any files to get Win32 support.</p>
<p>If you&#8217;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&#8217;s Settings File sections in my instructions.</p>
<div></div>
<div></div>
<div><span style="font-weight: bold;">The Path to the Win32 SDK is Slightly Different</span></div>
<div></div>
<div></div>
<p>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:</p>
<div></div>
<div><span style="font-family:'courier new';">C:\Program Files\Microsoft Platform SDK</span></div>
<div></div>
<p>If you install Visual C++ 2008 Express, you&#8217;ll find the Win32 SDK at the following path:</p>
<div></div>
<div><span style="font-family:'courier new';">C:\Program Files\Microsoft SDKs\Windows\v6.0A</span></div>
<div></div>
<p>The v6.0A is the Win32 SDK version. If you&#8217;re reading this in the future, the version number may change.</p>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2007/12/setting-up-sdl-with-visual-c-2008-express/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Changing SDL’s Working Directory on Mac OS X</title>
		<link>http://meandmark.com/blog/2007/12/changing-sdls-working-directory-on-mac-os-x/</link>
		<comments>http://meandmark.com/blog/2007/12/changing-sdls-working-directory-on-mac-os-x/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 20:45:00 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Mac Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://meandmark.com/blog/?p=56</guid>
		<description><![CDATA[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&#8217;s Resources folder. What would be nice would be to set the working directory to the [...]]]></description>
			<content:encoded><![CDATA[<p>The Mac OS X version of <span class="blsp-spelling-error" id="SPELLING_ERROR_0">SDL</span> 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&#8217;s Resources folder. What would be nice would be to set the working directory to the Resources folder. How do you do this?</p>
<p>You change the working directory by modifying the method -<span class="blsp-spelling-error" id="SPELLING_ERROR_1">setupWorkingDirectory</span>: in the file <span class="blsp-spelling-error" id="SPELLING_ERROR_2">SDLMain</span>.m. You&#8217;ll want to change the code in <span class="blsp-spelling-error" id="SPELLING_ERROR_3">SDLMain</span>.m in <span class="blsp-spelling-error" id="SPELLING_ERROR_4">SDL&#8217;s</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_5">Xcode</span> templates so your changes take effect for any new <span class="blsp-spelling-error" id="SPELLING_ERROR_6">SDL</span> 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 -<span class="blsp-spelling-error" id="SPELLING_ERROR_7">setupWorkingDirectory</span>: method:</p>
<p><code> </code>
<pre><span class="blsp-spelling-error" id="SPELLING_ERROR_8">NSString</span> *<span class="blsp-spelling-error" id="SPELLING_ERROR_9">resourcePath</span> = [[<span class="blsp-spelling-error" id="SPELLING_ERROR_10">NSBundle</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_11">mainBundle</span>] <span class="blsp-spelling-error" id="SPELLING_ERROR_12">resourcePath</span>];[[<span class="blsp-spelling-error" id="SPELLING_ERROR_13">NSFileManager</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_14">defaultManager</span>] <span class="blsp-spelling-error" id="SPELLING_ERROR_15">changeCurrentDirectoryPath</span>:<span class="blsp-spelling-error" id="SPELLING_ERROR_16">resourcePath</span>];</pre>
<p>Thanks to Keith Bauer, aka <span class="blsp-spelling-error" id="SPELLING_ERROR_17">OneSadCookie</span>, for the source code to change the working directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://meandmark.com/blog/2007/12/changing-sdls-working-directory-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/szymczyk/public_html/blog/wp-includes/feed-rss2.php:11) in <b>/home/szymczyk/public_html/blog/wp-includes/pluggable.php</b> on line <b>897</b><br />

