<?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>Tony Bhimani&#039;s Blog</title>
	<atom:link href="http://www.tonybhimani.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tonybhimani.com</link>
	<description>Where I Share my Linux + Mac + Programming Experiences</description>
	<lastBuildDate>Thu, 16 May 2013 22:03:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>AJAX: Learn The Basics Without Using Toolkit Libraries</title>
		<link>http://www.tonybhimani.com/2011/10/23/ajax-learn-the-basics-without-using-toolkit-libraries/</link>
		<comments>http://www.tonybhimani.com/2011/10/23/ajax-learn-the-basics-without-using-toolkit-libraries/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 05:00:28 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=408</guid>
		<description><![CDATA[AJAX is one of the popular acronym buzzwords in the world of web development technologies. It stands for Asynchronous JavaScript and XML. What it does is allow you to make your website far more dynamic by updating portions in realtime &#8230; <a href="http://www.tonybhimani.com/2011/10/23/ajax-learn-the-basics-without-using-toolkit-libraries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>AJAX is one of the popular acronym buzzwords in the world of web development technologies. It stands for Asynchronous JavaScript and XML. What it does is allow you to make your website far more dynamic by updating portions in realtime without page reloads (refreshes). This beginners AJAX tutorial will teach you how to write JavaScript code to do some simple screen updates. It&#8217;ll focus on a low-level AJAX implementation meaning JavaScript toolkits like jQuery and script.aculo.us will not be used (future tutorials will make use of these high-level time-saving tools). In my opinion, learning AJAX in this manner is far better because you&#8217;ll grasp the concept and it will help you move in the direction of using toolkits to simplify your coding (<em>you must crawl before you can walk&#8230;</em>). Also, this AJAX tutorial will be the first post in a series I plan on publishing regarding this subject.</p>
<p><strong>Phase 1: Writing the AJAX JavaScript Code &#8211; Making the Call</strong></p>
<p>I first learned AJAX from the <a href="http://www.w3schools.com/" rel="nofollow" target="_blank">W3Schools</a> website and will be using their code base as the foundation for this AJAX tutorial. The first step in working with AJAX is to create an object of <code>XMLHttpRequest</code>. The Firefox, Opera, Safari, and Internet Explorer browsers all handle this differently, however code wise the first three are the same. Internet Explorer (yes, Microsoft) has to take a unique approach (putting it nicely) which is different than the other mainstream web browsers. Getting back on point now, the code below is a modified version of what you can find from the W3Schools AJAX Guide for creating a object for <code>XMLHttpRequest</code> (the interface to make AJAX music).</p>
<pre class="code">function GetXmlHttpObject() {
  var xmlHttp = null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  } catch (e) {
    // Internet Explorer
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}</pre>
<p>The code starts with creating a variable handle for the <code>XMLHttpRequest</code> object and making it null. Within a <code>try</code> and <code>catch</code> block the <code>XMLHttpRequest()</code> method is called. If an object is created then exit the function and return the object. If the object can&#8217;t be created then the ActiveX (Microsoft) route is taken by using <code>Msxml2.XMLHTTP</code> and <code>Microsoft.XMLHTTP</code>. If this part fails as well, AJAX isn&#8217;t possible with the browser for whatever reason, otherwise after having called this <code>GetXmlHttpObject()</code> function we&#8217;ll have an AJAX object to work with. Next we&#8217;ll build an AJAX request.</p>
<pre class="code">// create xml http object
var objXmlHttp = GetXmlHttpObject();
// open a connection and send the ajax request
objXmlHttp.open("GET", "http://www.domain.com/ajaxresponder.php", true);
objXmlHttp.send();</pre>
<p>The AJAX request is composed of a call to the <code>open</code> and <code>send</code> methods of the <code>XmlHttpRequest</code> object. The <code>open</code> method takes three parameters (type of request [GET or POST], URL of the file on the server, and boolean true [asynchronous] or false [synchronous]).</p>
<ul>
<li>
<p><strong>Type of Request:</strong> GET or POST? Well, it depends on your requirements but most of the time you will be using GET for your AJAX calls. AJAX is information dependent meaning that what you give it will determine what it gives back to you. For example, say you&#8217;re providing a weather service and want to get the temperature for a specific zip code. That zip code would be passed as part of the URL in the query string. The file on the server would accept that input and give the temperature as output.</p>
</li>
<li>
<p><strong>URL of file on the server:</strong> This URL is where the processing of your data happens. The type of file will be a dynamic server-side scripting language such as PHP that can take your input (via GET or POST), process it, and send back formatted output that you will present to the user&#8217;s browser. Using the weather example from above, this script would take the zip code and possibly do a database lookup to get the temperature and pass it back to the AJAX caller.</p>
</li>
<li>
<p><strong>Asynchronous or Synchronous:</strong> Once again, depending on your requirements you may choose one option over the other. A high percentage of the time your calls will be asynchronous, which means that once the AJAX call is issued your browser won&#8217;t be held up waiting on the response; it can continue doing other tasks and once the response does come in it can be processed. One instance when a synchronous call would be necessary is when the response of a first AJAX call is required by a second call. If you keep it asynchronous then once the first AJAX call is done the second would run right away. There is no guarantee that the first call would be fast enough to get the result to pass to the second call, hence keeping it synchronous forces the order of operations to follow through. Be careful though! If the synchronous call takes a long time processing it can appear that your browser window has locked up!</p>
</li>
</ul>
<p><strong>Phase 2: Crafting a Server-Side PHP Script to Process AJAX Requests</strong></p>
<p>With the JavaScript code in place for invoking the AJAX call the server-side script to handle that call needs to be written. The sole purpose of this script will be to listen for the AJAX call, process the request, and send back output. Because this is AJAX tutorial is being written in a manner with beginners in mind, the server-side script is going to be extremely basic. What it will do is send back a random quote from a famous author. In the next tutorial I&#8217;ll take it up a notch by showing you how to integrate a database and fetching data.</p>
<p>I&#8217;ll be using PHP to write this server-side script because that is my preferred language, however you can use Perl CGI, Cold Fusion, Microsoft&#8217;s Active Server Pages, ASP.NET or another language as long as the server that will be hosting the script can support it. If you don&#8217;t know PHP then try and follow along and I&#8217;ll explain the code as I go.</p>
<pre class="code">&lt;?php

/************************************************
      AJAX FAMOUS AUTHOR QUOTE SCRIPT
  Quotes Source: www.famousquotesandauthors.com
*************************************************/

// we use an array for the famous author quotes
$quotes_arr = array(
&quot;I know only that what is moral is what you feel good after and what is immoral is what you feel bad after. - Ernest Hemingway&quot;,
&quot;Eve left Adam, to meet the Devil in private. - Alexander Pope&quot;,
&quot;Democracy is based on the conviction that man has the moral and intellectual capacity, as well as the inalienable right, to govern himself with reason and justice. - Harry S. Truman&quot;,
&quot;Crime is a logical extension of the sort of behaviour that is often considered perfectly respectable in legitimate business. - Robert Rice&quot;,
&quot;By time and toil we sever What strength and rage could never. - Jean de la Fontaine&quot;,
&quot;Human history is in essence a history of ideas. - H. G. Wells&quot;
);

// the quotes are chosen randomly
$quote_choice = rand(0, sizeof($quotes_arr) - 1);

// echo the random quote
echo $quotes_arr[$quote_choice];

?&gt;
</pre>
<p>This is a very simple PHP script. All it does is define a six string array with the variable name of <code>$quotes_arr</code>. One of those six quotes is chosen at random using the PHP <code>rand()</code> function. What <code>rand()</code> will do is pick a random number between 0 and the size of the array less one (6 &#8211; 1 = 5) to serve as an index for choosing a string from the array. Note: PHP arrays are zero-based indexing meaning the first element begins at zero, not one. Finally, using PHP&#8217;s <code>echo</code> the chosen quote string is printed out to the browser.</p>
<p><strong>Phase 3: Putting All This AJAX &amp; PHP Coding Stuff Together</strong></p>
<p>The pieces to this AJAX puzzle are on the table, it&#8217;s time to fit them together. We&#8217;ve learned how to build an AJAX request and what an AJAX processing script can look like, the last step is to build the HTML page that makes use of them. The mechanics will be once the page loads the AJAX request will be made, the famous quote will be received from the server-side script, and the quote will be written to the HTML page. I&#8217;ve also included a button that can be clicked to load a new quote when clicked.</p>
<pre class="code">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;  dir=&quot;ltr&quot; lang=&quot;en-US&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
&lt;title&gt;AJAX Tutorial: Random Famous Quotes&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
function GetXmlHttpObject() {
  var xmlHttp = null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  } catch (e) {
    // Internet Explorer
    try {
      xmlHttp = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);
    } catch (e) {
      xmlHttp = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
    }
  }
  return xmlHttp;
}
// create xml http object
var objXmlHttp = GetXmlHttpObject();
// open a connection and send the ajax request
objXmlHttp.open(&quot;GET&quot;, &quot;http://www.tonybhimani.com/files/2011/10/ajax-quotes.php&quot;, true);
objXmlHttp.send();
objXmlHttp.onreadystatechange=function() {
  if (objXmlHttp.readyState == 4 &#038;&#038; objXmlHttp.status == 200) {
    document.getElementById(&quot;quotes&quot;).innerHTML = objXmlHttp.responseText;
  }
}
// --&gt;
&lt;/script&gt;
&lt;p&gt;&lt;strong&gt;Random Quote of the Day&lt;/strong&gt;&lt;/p&gt;
&lt;p id=&quot;quotes&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;input type=&quot;button&quot; name=&quot;reload&quot; value=&quot;Reload Page&quot; onclick=&quot;javascript:window.location.reload(true);&quot; /&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You may notice I&#8217;ve added some extra code to the AJAX JavaScript section. Because this is an asynchronous call we have to declare an event handler. An event handler is a code block that sits around and waits for an event to occur before it executes its code. Our event handler (JavaScript function) is attached to the <code>onreadystatechange</code> event of the <code>XMLHttpRequest</code> object. It will get executed when the ready state changes. We check two <code>XMLHttpRequest</code> properties <code>readyState</code> and <code>status</code> for specific values. Once these values are attained (<code>readyState</code> of 4 meaning all data has been received and HTTP status of 200) we then use <code>getElementById</code> and change the HTML code between the start and end tags of the P with the id of quotes using this <code>innerHTML</code> property.</p>
<p>Okay, we&#8217;ve reached the end of this beginner&#8217;s AJAX tutorial. I&#8217;ve been talking about AJAX this whole time and I&#8217;m sure you&#8217;re eager to finally see the AJAX code in action. Below is a link to the sample page where you will see a randomly pulled quote from the PHP AJAX script. Click the Reload Page button to see another quote from the PHP array.</p>
<p><a href="http://www.tonybhimani.com/files/2011/10/famous-quotes.html" title="AJAX Tutorial for Beginners: Random Famous Author Quotes" target="_blank"><strong>AJAX Tutorial for Beginners: Random Famous Author Quotes</strong></a></p>
<p>Source Code Download: <a href="http://www.tonybhimani.com/files/2011/10/ajax-tutorial-1-no-toolkits1.zip" title="AJAX Tutorial for Beginners 1 [ No Toolkits ]">AJAX Tutorial for Beginners 1 [ No Toolkits ] (Zip)</a></p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D408&count=vertical&related=&text=AJAX%3A%20Learn%20The%20Basics%20Without%20Using%20Toolkit%20Libraries' class='twitter-share-button' data-text='AJAX: Learn The Basics Without Using Toolkit Libraries' data-url='http://www.tonybhimani.com/?p=408' data-counturl='http://www.tonybhimani.com/2011/10/23/ajax-learn-the-basics-without-using-toolkit-libraries/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/10/23/ajax-learn-the-basics-without-using-toolkit-libraries/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/10/23/ajax-learn-the-basics-without-using-toolkit-libraries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript: Controlling a Popup Window&#8217;s Parent Window</title>
		<link>http://www.tonybhimani.com/2011/10/16/javascript-controlling-a-popup-windows-parent-window/</link>
		<comments>http://www.tonybhimani.com/2011/10/16/javascript-controlling-a-popup-windows-parent-window/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 06:47:33 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Control Windows]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Popup Parent]]></category>
		<category><![CDATA[Popup Window]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=363</guid>
		<description><![CDATA[You may find it useful to control a parent window from a generated popup window, such as being able to manipulate its look, content, etc. One example being a web application I wrote for work. In the portion for entering &#8230; <a href="http://www.tonybhimani.com/2011/10/16/javascript-controlling-a-popup-windows-parent-window/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You may find it useful to control a parent window from a generated popup window, such as being able to manipulate its look, content, etc. One example being a web application I wrote for work. In the portion for entering a new sales order, products are added from a popup search window. When the product being added is selected, a button is clicked and the parent window&#8217;s line item table is modified to include the selected product. This is only one example as many others exist. This tutorial will discuss how to launch a popup window and change properties of the parent (colors, fonts, sizes, and styles).</p>
<p><a href="http://www.tonybhimani.com/files/2011/10/Parent_Window.png"><img class="alignleft size-medium wp-image-370" title="Parent Window Screenshot for JavaScript Manipulation" src="http://www.tonybhimani.com/files/2011/10/Parent_Window-300x215.png" alt="Parent Window Screenshot for JavaScript Manipulation" width="300" height="215" /></a> We begin with creating the parent window. There won&#8217;t anything fancy with it, just a H1 title, a couple paragraphs of text, and a link to launch the popup window controller. To the left is a screenshot of what our parent window will look like when the HTML has been added. In the code some elements have been added to allow us to use JavaScript to control (manipulate) the contents of the parent window. Namely id attributes for the H1 and P tags for use the the Document Object Method <code>getElementById</code>.</p>
<p>Parent Window HTML + JavaScript Code ( parent-window.html ):</p>
<pre class="code">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr" lang="en-US"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;The Parent Window [ JavaScript: Controlling a Popup Window's Parent Window ]&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1 id="page_title"&gt;The Parent Window&lt;/h1&gt;
&lt;p id="paragraph1"&gt;This is the window that will be controlled by the popup window.&lt;/p&gt;
&lt;p id="paragraph2"&gt;Click the link below to open the popup window controller.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="#" onclick="javascript:window.open('popup-window.html','popupwindow','width=450,height=250,menu=0,status=0');"&gt;Launch Popup Window&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;small&gt;Note: Please disable any popup blocker software if you don't see the popup window.&lt;/small&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>You&#8217;ll see that the code for opening the popup window is located in the href onclick. The JavaScript <code>window.open</code> is called and the popup window filename is passed as the first parameter, followed by a name for the window, and lastly the specs for the window appearance (width, height, hide the menu and status bars).</p>
<p><a href="http://www.tonybhimani.com/files/2011/10/Popup_Window.png"><img class="alignleft size-medium wp-image-380" title="Popup Window Screenshot for JavaScript Parent Window Manipulation" src="http://www.tonybhimani.com/files/2011/10/Popup_Window-300x222.png" alt="Popup Window Screenshot for JavaScript Parent Window Manipulation" width="300" height="222" /></a> With the parent window created the next step is to create the popup window. The purpose of the popup window is to control its parent window. For this demonstration it&#8217;s accomplished through a series of buttons that call JavaScript functions that alter the parent window&#8217;s properties (as seen on the left). I have created buttons that change the window&#8217;s background color, the font family for the H1 title, the font size for the first paragraph, the font style for the second paragraph, and to reload the parent window page. Obviously I&#8217;m only scratching the surface here as much more can be done with JavaScript to alter the parent window.</p>
<p>Popup Window HTML + JavaScript Code ( popup-window.html ):</p>
<pre class="code">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;  dir=&quot;ltr&quot; lang=&quot;en-US&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
&lt;title&gt;The Popup Window [ JavaScript: Controlling a Popup Window's Parent Window ]&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
var parent_window = window.opener;
var bgcolor_index = 0;
var h1font_index = 0;
var para1_index = 0;
var para2_index = 0;

function backgroundColor() {
  var colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#00ffff', '#cccccc', '#ffffff'];
  if (parent_window &#038;&#038; !parent_window.closed) {
    parent_window.document.body.style.backgroundColor = colors[bgcolor_index];
    if (++bgcolor_index &gt; colors.length - 1) { bgcolor_index = 0; }
  }
}

function h1TitleFontFamily() {
  var fonts = ['Arial', 'Helvectica', 'Sans Serif', 'Verdana', 'Times New Roman'];
  if (parent_window &#038;&#038; !parent_window.closed) {
    var page_title = parent_window.document.getElementById('page_title');
    page_title.style.fontFamily = fonts[h1font_index];
    if (++h1font_index &gt; fonts.length - 1) { h1font_index = 0; }
  }
}

function paragraph1FontSize() {
  var sizes = ['8pt', '12pt', '16pt', '20pt', '32pt', '64pt'];
  if (parent_window &#038;&#038; !parent_window.closed) {
    var paragraph1 = parent_window.document.getElementById('paragraph1');
    paragraph1.style.fontSize = sizes[para1_index];
    if (++para1_index &gt; sizes.length - 1) { para1_index = 0; }
  }
}

function paragraph2FontStyle() {
  var styles = ['oblique', 'italic', 'normal'];
  if (parent_window &#038;&#038; !parent_window.closed) {
    var paragraph2 = parent_window.document.getElementById('paragraph2');
    paragraph2.style.fontStyle = styles[para2_index];
    paragraph2.style.fontWeight = 'bold';
    if (++para2_index &gt; styles.length - 1) {
      para2_index = 0;
      paragraph2.style.fontWeight = '';
    }
  }
}

function reloadParent() {
  if (parent_window &#038;&#038; !parent_window.closed) {
    parent_window.location.reload(true);
  }
}
// --&gt;
&lt;/script&gt;
&lt;h1 align=&quot;center&quot;&gt;The Popup Window&lt;/h1&gt;
&lt;table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;10&quot; cellspacing=&quot;0&quot;&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot; valign=&quot;middle&quot;&gt;&lt;input type=&quot;button&quot; name=&quot;button1&quot; id=&quot;button1&quot; value=&quot;Background Color&quot; onclick=&quot;backgroundColor();&quot; /&gt;&lt;/td&gt;
&lt;td align=&quot;center&quot; valign=&quot;middle&quot;&gt;&lt;input type=&quot;button&quot; name=&quot;button2&quot; id=&quot;button2&quot; value=&quot;H1 Title Font Family&quot; onclick=&quot;h1TitleFontFamily();&quot; /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot; valign=&quot;middle&quot;&gt;&lt;input type=&quot;button&quot; name=&quot;button3&quot; id=&quot;button3&quot; value=&quot;Paragraph 1 Font Size&quot; onclick=&quot;paragraph1FontSize();&quot; /&gt;&lt;/td&gt;
&lt;td align=&quot;center&quot; valign=&quot;middle&quot;&gt;&lt;input type=&quot;button&quot; name=&quot;button4&quot; id=&quot;button4&quot; value=&quot;Paragraph 2 Font Style&quot; onclick=&quot;paragraph2FontStyle();&quot; /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;center&quot; valign=&quot;middle&quot; colspan=&quot;2&quot;&gt;&lt;input type=&quot;button&quot; name=&quot;button5&quot; id=&quot;button5&quot; value=&quot;Reload Parent Window&quot; onclick=&quot;reloadParent();&quot; /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>I&#8217;m not going to go over all the code. The key to making the popup control the parent is the <code>Window</code> object&#8217;s <code>opener</code> property ala <code>window.opener</code>. In my code I assign it to a variable called <code>parent_window</code> which I use throughout my functions. By referencing it in front of the <code>document</code> object you can hook into the window properties of the parent much like you would for any foreground window. Having done so you now have access to <code>getElementById</code> and other Document Object Methods to get a handle to the object. Add some creative JavaScript and you can build some pretty interesting web applications with popup windows.</p>
<p>That&#8217;s it in a nutshell so enough talk. I&#8217;m sure you want see it in action, so try out the <a href="http://www.tonybhimani.com/files/2011/10/parent-window.html" title="Controlling a Popup Window's Parent Window Demonstration" target="_blank"><strong>Controlling a Popup Window&#8217;s Parent Window Demonstration</strong></a>.</p>
<p>Source Code Download: <a href="http://www.tonybhimani.com/files/2011/10/parent-window-controller.zip" title="Control a Parent Window by Popup using JavaScript Source Code (Zip)">Control a Parent Window by Popup using JavaScript (Zip)</a></p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D363&count=vertical&related=&text=JavaScript%3A%20Controlling%20a%20Popup%20Window%26%23039%3Bs%20Parent%20Window' class='twitter-share-button' data-text='JavaScript: Controlling a Popup Window&#039;s Parent Window' data-url='http://www.tonybhimani.com/?p=363' data-counturl='http://www.tonybhimani.com/2011/10/16/javascript-controlling-a-popup-windows-parent-window/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/10/16/javascript-controlling-a-popup-windows-parent-window/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/10/16/javascript-controlling-a-popup-windows-parent-window/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP: Checkbox Arrays with Javascript Usage</title>
		<link>http://www.tonybhimani.com/2011/10/15/php-checkbox-arrays-with-javascript-usage/</link>
		<comments>http://www.tonybhimani.com/2011/10/15/php-checkbox-arrays-with-javascript-usage/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 10:12:22 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Arrays]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[HTML Forms]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=314</guid>
		<description><![CDATA[If you&#8217;ve created HTML forms then you&#8217;ll have used checkboxes and radio buttons for gathering user input. Taking it a step further you would link your form with a server-side scripting language such as PHP to capture the user input &#8230; <a href="http://www.tonybhimani.com/2011/10/15/php-checkbox-arrays-with-javascript-usage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve created HTML forms then you&#8217;ll have used checkboxes and radio buttons for gathering user input. Taking it a step further you would link your form with a server-side scripting language such as PHP to capture the user input and process it. Things get a little tricky when you have groups of checkboxes or radio buttons in your form. Once you create a group of these same control types you form what is known as an array. An array is simply an integer-indexed collection of objects. When defining a checkbox or radio button you need to give it a name. This naming convention allows you to access the value of the control object and use it for whatever purpose you need (store it, email it, etc).</p>
<pre class="code">&lt;form action=&quot;#&quot;&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;language&quot; value=&quot;English&quot; /&gt; I speak English&lt;br /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;language&quot; value=&quot;French&quot; /&gt; I speak French
&lt;/form&gt;
</pre>
<p>Above is an example of two checkboxes for choosing a spoken language. Notice how they both share the same name <em>language</em> to create an array (more precisely a nodelist of elements).</p>
<pre class="code">&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
function showMyChoices1() {
  var strChoices = &quot;&quot;
  var objCBarray = document.getElementsByName('language');
  for (i = 0; i &lt; objCBarray.length; i++) {
    if (objCBarray[i].checked) {
      strChoices += &quot;* &quot; + objCBarray[i].value + &quot;\n&quot;;
    }
  }
  if (strChoices.length &gt; 0) {
    var strMessage = &quot;You speak\n&quot; + strChoices;
    alert(strMessage);
  } else {
    alert(&quot;Please choose your spoken language(s).&quot;);
  }}
// --&gt;
&lt;/script&gt;
</pre>
<p>Next I have created a simple function called <em>showMyChoices1</em> that loops through the checkboxes, creates a message, and displays it using an alert. The variable <em>objCBarray</em> is a handle for the checkbox nodelist acquired by using <code>getElementsByName</code> Document Object Method. Using a for loop to iterate through each checkbox (the loop count is determined by the length property), the checked ones get added to a string called <em>strChoices</em>. After the for loop is finished the length of the string is tested for a value greater than zero. If it tests positive then an alert is shown with the checked values, otherwise a message prompting the user to select a language is shown.</p>
<p>Let&#8217;s put it all together (including a button) and see it in action. Try it below.<script type="text/javascript" language="JavaScript"><!--
function showMyChoices1() {
  var strChoices = "";
  var objCBarray = document.getElementsByName('language');
  for (i = 0; i < objCBarray.length; i++) {
    if (objCBarray[i].checked) {
      strChoices += "* " + objCBarray[i].value + "\n";
    }
  }
  if (strChoices.length > 0) {
    var strMessage = "You speak\n" + strChoices;
    alert(strMessage);
  } else {
    alert("Please choose your spoken language(s).");
  }
}
// --></script><br />
<form action="#"><input type="checkbox" name="language" value="English" /> I speak English<br /><input type="checkbox" name="language" value="French" /> I speak French<br /><input type="button" value="Show My Choices" onclick="showMyChoices1();" /></form>
<p>Here is the code for the JavaScript only version.</p>
<pre class="code">&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
function showMyChoices1() {
  var strChoices = &quot;&quot;;
  var objCBarray = document.getElementsByName('language');
  for (i = 0; i &lt; objCBarray.length; i++) {
    if (objCBarray[i].checked) {
      strChoices += &quot;* &quot; + objCBarray[i].value + &quot;\n&quot;;
    }
  }
  if (strChoices.length &gt; 0) {
    var strMessage = &quot;You speak\n&quot; + strChoices;
    alert(strMessage);
  } else {
    alert(&quot;Please choose your spoken language(s).&quot;);
  }
}
// --&gt;
&lt;/script&gt;
&lt;form action=&quot;#&quot;&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;language&quot; value=&quot;English&quot; /&gt; I speak English&lt;br /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;language&quot; value=&quot;French&quot; /&gt; I speak French&lt;br /&gt;
&lt;input type=&quot;button&quot; value=&quot;Show My Choices&quot; onclick=&quot;showMyChoices1();&quot; /&gt;
&lt;/form&gt;
</pre>
<p>If you plan on using PHP to process your form data then the way the checkboxes were named isn&#8217;t going to work. PHP requires you to name the variable in an array manner. It&#8217;s basically the same as before but you have to add trailing square brackets []. For example, I used <em>language</em> for the name of my checkboxes. To make this work with PHP I&#8217;ll need to use <em>language[]</em>. Having made this change the JavaScript function I&#8217;ve created won&#8217;t work because of the variable name in <code>getElementsByName</code> (be it with or without the brackets, no bueno). Square brackets in JavaScript have a special meaning so two changes need to be made to my code.</p>
<p>The first change is to add an id to the &lt;form&gt; tag so it can be accessed via <code>getElementById</code> (now I&#8217;ll be using this HTML DOM method in place of <code>getElementsByName</code>). The second change is in how I call the <code>getElementById</code>. Notice the notation of how I reference the id of my form and then my checkboxes (BTW, this second function version uses <em>food[]</em> checkboxes). The rest of the function remains the same.</p>
<pre class="code">&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
function showMyChoices2() {
  var strChoices = &quot;&quot;;
  var objCBarray = document.getElementById('myform')['food[]'];
</pre>
<p>Try out the PHP + JavaScript version below.<script type="text/javascript" language="JavaScript"><!--
function showMyChoices2() {
  var strChoices = "";
  var objCBarray = document.getElementById('myform')['food[]'];
  for (i = 0; i < objCBarray.length; i++) {
    if (objCBarray[i].checked) {
      strChoices += "* " + objCBarray[i].value + "\n";
    }
  }
  if (strChoices.length > 0) {
    var strMessage = "Your favorite food(s)\n" + strChoices;
    alert(strMessage);
  } else {
    alert("Please choose your favorite foods.");
  }
}
// --></script><br />
<form id="myform" action="#">
<p>My favorite food is?</p>
<p><input type="checkbox" name="food[]" value="Burgers" /> Burgers<br /><input type="checkbox" name="food[]" value="Pizza" /> Pizza<br /><input type="checkbox" name="food[]" value="Spaghetti" /> Spaghetti<br /><input type="checkbox" name="food[]" value="Tamales" /> Tamales<br /><input type="button" value="Show My Choices" onclick="showMyChoices2();" /></form>
<p>Here is the code for the PHP + JavaScript version.</p>
<pre class="code">&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
function showMyChoices2() {
  var strChoices = &quot;&quot;;
  var objCBarray = document.getElementById('myform')['food[]'];
  for (i = 0; i &lt; objCBarray.length; i++) {
    if (objCBarray[i].checked) {
      strChoices += &quot;* &quot; + objCBarray[i].value + &quot;\n&quot;;
    }
  }
  if (strChoices.length &gt; 0) {
    var strMessage = &quot;Your favorite food(s)\n&quot; + strChoices;
    alert(strMessage);
  } else {
    alert(&quot;Please choose your favorite foods.&quot;);
  }
}
// --&gt;
&lt;/script&gt;
&lt;form id=&quot;myform&quot; action=&quot;#&quot;&gt;
&lt;p&gt;My favorite food is?&lt;/p&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;food[]&quot; value=&quot;Burgers&quot; /&gt; Burgers&lt;br /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;food[]&quot; value=&quot;Pizza&quot; /&gt; Pizza&lt;br /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;food[]&quot; value=&quot;Spaghetti&quot; /&gt; Spaghetti&lt;br /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;food[]&quot; value=&quot;Tamales&quot; /&gt; Tamales&lt;br /&gt;
&lt;input type=&quot;button&quot; value=&quot;Show My Choices&quot; onclick=&quot;showMyChoices2();&quot; /&gt;
&lt;/form&gt;
</pre>
<p>All that would be left to do is build a PHP script to process the form submission data and set the script&#8217;s file name as the action in the &lt;form&gt; tag. That&#8217;s beyond the scope of this post, however if you need help doing it, post a comment. Using this code you should now be able to use client-side JavaScript to preprocess form data before it hits the server using standard variable names and PHP array type ones.</p>
<p>Source Code Download: <a href='http://www.tonybhimani.com/files/2011/10/js-php-checkboxes.zip'>JavaScript PHP Checkbox Array Source Code (Zip)</a></p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D314&count=vertical&related=&text=PHP%3A%20Checkbox%20Arrays%20with%20Javascript%20Usage' class='twitter-share-button' data-text='PHP: Checkbox Arrays with Javascript Usage' data-url='http://www.tonybhimani.com/?p=314' data-counturl='http://www.tonybhimani.com/2011/10/15/php-checkbox-arrays-with-javascript-usage/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/10/15/php-checkbox-arrays-with-javascript-usage/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/10/15/php-checkbox-arrays-with-javascript-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome Home MacBook Pro, I Missed You!</title>
		<link>http://www.tonybhimani.com/2011/09/24/welcome-home-macbook-pro-i-missed-you/</link>
		<comments>http://www.tonybhimani.com/2011/09/24/welcome-home-macbook-pro-i-missed-you/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 16:44:11 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[MacBook]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=240</guid>
		<description><![CDATA[Last Friday, the 16th, my MacBook went off to be repaired. I got it back yesterday (a week later). They replaced the LCD and did something to the video. My MacBook Pro is running like a champ again. This repair &#8230; <a href="http://www.tonybhimani.com/2011/09/24/welcome-home-macbook-pro-i-missed-you/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tonybhimani.com/files/2011/09/silver-apple-logo.png"><img class="alignleft size-full wp-image-241" title="Silver Apple Logo" src="http://www.tonybhimani.com/files/2011/09/silver-apple-logo.png" alt="Silver Apple Logo" width="104" height="130" /></a>Last Friday, the 16th, my MacBook went off to be repaired. I got it back yesterday (a week later). They replaced the LCD and did something to the video. My MacBook Pro is running like a champ again. This repair job cost me $350 that I didn&#8217;t have, but I needed it fixed so I could get back to learning Apple development. My fingers are crossed the video doesn&#8217;t go out again, but if you must die on me <em>Mac hardware</em>, please be so kind as to do it before the 90-day warranty expires.</p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D240&count=vertical&related=&text=Welcome%20Home%20MacBook%20Pro%2C%20I%20Missed%20You%21' class='twitter-share-button' data-text='Welcome Home MacBook Pro, I Missed You!' data-url='http://www.tonybhimani.com/?p=240' data-counturl='http://www.tonybhimani.com/2011/09/24/welcome-home-macbook-pro-i-missed-you/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/09/24/welcome-home-macbook-pro-i-missed-you/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/09/24/welcome-home-macbook-pro-i-missed-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Mac OS Content Will Have To Wait&#8230;</title>
		<link>http://www.tonybhimani.com/2011/09/14/new-mac-os-content-will-have-to-wait/</link>
		<comments>http://www.tonybhimani.com/2011/09/14/new-mac-os-content-will-have-to-wait/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 17:05:13 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[MacBook]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=236</guid>
		<description><![CDATA[I had written a few Mac related posts and was going to continue with that theme for a while, however my MacBook Pro took a dump. This is old news to me, but new news to you because it actually &#8230; <a href="http://www.tonybhimani.com/2011/09/14/new-mac-os-content-will-have-to-wait/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had written a few Mac related posts and was going to continue with that theme for a while, however my MacBook Pro took a dump. This is old news to me, but new news to you because it actually all went down over a month ago and I&#8217;ve been too lazy to write about it.</p>
<p>The night it began I was fiddling with Unity3D and all of a sudden my screen did something I had never seen before on any of my computers. Putting this into words is very difficult as what I saw is hard to explain. It looked as if tiny pieces of my screen were cutout and replaced with black emptiness &#8211; similar to a patch pattern or something like that. Think of taking a finely knit blanket, stretching it out so the little holes are slightly enlarged, then overlay that on your screen. Visualize it being inverted, being the solid part transparent and the holes will be black. That in a nutshell is what my screen looked like. Anyway, I rebooted and the same deal happened when it came back up. I gave up and turned the laptop off for the night. The next day it was fine and was running normal for a week until one night the screen turned off. I powered it off and tried it again. Now it&#8217;s finally toast. It gets power (keyboard lights up, hard drive revs up, etc) but just no screen.</p>
<p>I Googled some things to try but nothing has worked. Diagnosing hardware isn&#8217;t my area of expertise, but from what I can gather either the screen is bad or the video card crapped out. I&#8217;ve been told this is a common problem with first generation MacBook laptops(?). I also called a few places and apparently it&#8217;ll cost between $250-$400 to have my MacBook repaired. I hooked up a DVI cable and I didn&#8217;t get anything on my external monitor so I&#8217;m leaning more towards the video card dying.</p>
<p>I&#8217;m not in a rush to have my MacBook fixed. My future articles are going to cover Linux. I was thinking of writing Linux versions of my Ogre3D posts.</p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D236&count=vertical&related=&text=New%20Mac%20OS%20Content%20Will%20Have%20To%20Wait...' class='twitter-share-button' data-text='New Mac OS Content Will Have To Wait...' data-url='http://www.tonybhimani.com/?p=236' data-counturl='http://www.tonybhimani.com/2011/09/14/new-mac-os-content-will-have-to-wait/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/09/14/new-mac-os-content-will-have-to-wait/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/09/14/new-mac-os-content-will-have-to-wait/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ogre3D SDK 1.7.3 for Apple iPhone iOS HOWTO</title>
		<link>http://www.tonybhimani.com/2011/07/09/ogre3d-sdk-1-7-3-for-apple-iphone-ios-howto/</link>
		<comments>http://www.tonybhimani.com/2011/07/09/ogre3d-sdk-1-7-3-for-apple-iphone-ios-howto/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 06:12:02 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[3D Graphics]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Ogre3D]]></category>
		<category><![CDATA[CMake]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Ogre Samples]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=179</guid>
		<description><![CDATA[Welcome to my third installment for Ogre3D on the Mac platform. This tutorial will describe the steps to installing the Ogre3D SDK version 1.7.3 Apple iPhone iOS release on Mac OS X. I&#8217;ll also go over installing the Ogre Xcode &#8230; <a href="http://www.tonybhimani.com/2011/07/09/ogre3d-sdk-1-7-3-for-apple-iphone-ios-howto/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Welcome to my third installment for Ogre3D on the Mac platform. This tutorial will describe the steps to installing the Ogre3D SDK version 1.7.3 Apple iPhone iOS release on Mac OS X. I&#8217;ll also go over installing the Ogre Xcode iPhone Template for generating a default iOS project and building the Ogre Samples Browser project. Although this sounds like a lot of information to cover, much of the groundwork was explained in my first guide for Mac OS X Ogre SDK and my second one outlining how to build the Ogre Samples Browser. I highly recommend reading those before continuing any further with these instructions because I won&#8217;t discuss installing Xcode, the NVIDIA Cg Toolkit, or CMake. My two prior Ogre tutorials can be found below.</p>
<ul>
<li><a title="Click to visit Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)" href="http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/">Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)</a></li>
<li><a title="Click to vist Building the Ogre3D SDK Samples on Mac OS X" href="http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/">Building the Ogre3D SDK Samples on Mac OS X</a></li>
</ul>
<p><strong>Step 1 &#8211; Download &amp; Install Ogre SDK 1.7.3 for iPhone &amp; iOS Dependencies</strong></p>
<p>Much like my OSX Ogre tutorial, I&#8217;m sticking to the prebuilt release of the Ogre SDK for iPhone. Perhaps in the future I&#8217;ll write up a doc on building the Ogre SDK from source, but now is not the time. First thing is we&#8217;ll do is download the Ogre SDK for iPhone. This guide is written for the version 1.7.3 of Ogre3D which is the current release at this time. Visit the Ogre website to download the <a title="Ogre 1.7.3 SDK for iPhone" href="http://www.ogre3d.org/download/sdk" target="_blank">Ogre 1.7.3 SDK for iPhone</a>. Follow the link for the Ogre iPhone SDK. Download the iPhone SDK to your computer (it&#8217;ll be a DMG disk image called OgreSDK_iOS_v1-7-3.dmg) and mount it (double-click it).<a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_SDK_iPhone_DMG_File_Window.png"><img class="alignleft size-medium wp-image-186" title="MacOSX Ogre SDK iPhone DMG File Window" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_SDK_iPhone_DMG_File_Window-169x300.png" alt="MacOSX Ogre SDK iPhone DMG File Window" width="169" height="300" /></a></p>
<p>After the disk image mounts, a mock iPhone window appears. There is a folder called OgreSDK that you&#8217;ll need to copy to your hard drive. This contains [almost] everything you need to build iPhone Ogre apps. In this tutorial we&#8217;ll drop the Ogre SDK into the hard drive root. Now if you followed my Ogre Mac OSX tutorial then we&#8217;ll have a name conflict because there is already a /OgreSDK, so copy the OgreSDK folder from the iPhone window to somewhere like your Desktop. Rename it to OgreSDK_iOS and move it to /OgreSDK_iOS (i.e. open a Finder window and drag it over to the hard drive root). So now we have the Ogre iOS SDK installed, the next step is to install the Ogre SDK iPhone iOS Dependencies.</p>
<p><img class="alignright size-medium wp-image-189" title="MacOSX Ogre iPhone SDK Dependencies Window" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_iPhone_SDK_Dependencies_Window-300x204.png" alt="MacOSX Ogre iPhone SDK Dependencies Window" width="178" height="121" /></p>
<p>The <a title="Click to visit Ogre iOS dependencies at SourceForge" href="http://sourceforge.net/projects/ogre/files/" target="_blank">Ogre iOS dependencies</a> DMG file can be found at SourceForge. Follow the <em>ogre-dependencies-mac -&gt; 1.7</em> path to get to the Ogre iOS precompiled dependencies DMG file. Download <a title="Click to download Ogre_iOS_4.3_Dependencies_20110411.dmg" href="http://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.7/Ogre_iOS_4.3_Dependencies_20110411.dmg/download">Ogre_iOS_4.3_Dependencies_20110411.dmg</a> and mount the disk image. You&#8217;ll see a iPhoneDependencies folder. Copy it and paste it inside of the iPhone SDK folder /OgreSDK_iOS.</p>
<p>That&#8217;s all there is to getting the Ogre SDK for iPhone set up on Mac OS X. The next task we&#8217;ll move on to is building the Ogre iPhone Samples Browser and running it in the iPhone iOS Simulator.</p>
<p><strong>Step 2 &#8211; Generate a Xcode Project for the iPhone Samples Browser</strong></p>
<p>Building the Ogre Samples Browser for the iPhone is very similar to how it&#8217;s built for OSX. Both procedures utilize CMake to create a new [working] copy of a Xcode project. However, in regards to making a new Xcode iPhone project, we do have to add one extra step to the CMake process, and that&#8217;s adding a new boolean name/value property called OGRE_BUILD_PLATFORM_IPHONE.</p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_CMake_OgreSDK_iOS_Add_Property.png"><img class="alignleft size-medium wp-image-194" title="MacOSX CMake OgreSDK iOS Add Property" src="http://www.tonybhimani.com/files/2011/07/MacOSX_CMake_OgreSDK_iOS_Add_Property-300x276.png" alt="MacOSX CMake OgreSDK iOS Add Property" width="270" height="248" /></a><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_CMake_OgreSDK_iOS_Generate_Xcode.png"><img class="alignleft size-medium wp-image-195" title="MacOSX CMake OgreSDK iOS Generate Xcode Project" src="http://www.tonybhimani.com/files/2011/07/MacOSX_CMake_OgreSDK_iOS_Generate_Xcode-300x276.png" alt="MacOSX CMake OgreSDK iOS Generate Xcode Project" width="270" height="248" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Fire up CMake. Set the location of the Ogre iOS SDK with the <em>Browse Source</em> button (/OgreSDK_iOS) and set the location of where to build the binaries with the <em>Browse Build</em> button (/OgreSDK_iOS). Click the <em>Configure</em> button, set the project generator as <em>Xcode</em>, and choose <em>Use default native compilers</em>. Once the process has finished you&#8217;ll see a lot of red. Click the <em>Add Entry</em> button up top. In the <em>Add Cache Entry</em> dialog box, for the Name field enter <em>OGRE_BUILD_PLATFORM_IPHONE</em>, set the Type to <em>BOOL</em>, and make sure Value is <em>checked</em>, then click <em>OK</em>. Finally, click <em>Configure</em> twice (once after each configuration process completes) and then the <em>Generate</em> button. The new Xcode project OGRE.xcodeproj for building the Ogre iOS SDK Samples Browser is ready to use.</p>
<p><strong>Step 3 &#8211; Build the Ogre SDK iPhone Samples Browser Project in Xcode</strong></p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Project_Build_Ogre_iPhone_App.png"><img class="alignleft size-medium wp-image-204" title="MacOSX Xcode Project Build Ogre iPhone App" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Project_Build_Ogre_iPhone_App-300x220.png" alt="MacOSX Xcode Project Build Ogre iPhone App" width="300" height="220" /></a>With our Ogre iOS project in hand we&#8217;re ready to build the Samples Browser. The Ogre Xcode project for iPhone is located in the root of your OgreSDK iOS install directory (/OgreSDK_iOS). It&#8217;s called OGRE.xcodeproj (same as the OSX version of the project). Launch Xcode and open the project or just double-click the .xcodeproj file. Unlike the OSX project where we had to make some changes to compile without error, the Ogre iPhone project works out of the box without modification. Click the <em>Build and Run</em> icon in the toolbar (or click the <em>Build</em> menu and select <em>Build and Run</em>). It&#8217;ll take some time for the Ogre iPhone Project to compile. Once it&#8217;s done compiling the iOS Simulator will open and the Ogre iPhone Samples Browser demo will launch.</p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_iPhone_iOS_Simulator_Ogre_Samples_Browser.png"><img class="alignright size-medium wp-image-205" title="MacOSX iPhone iOS Simulator Ogre Samples Browser" src="http://www.tonybhimani.com/files/2011/07/MacOSX_iPhone_iOS_Simulator_Ogre_Samples_Browser-300x159.png" alt="MacOSX iPhone iOS Simulator Ogre Samples Browser" width="300" height="159" /></a>To the right is a screenshot of one the demo samples from the project. Using the demo from the simulator is somewhat difficult. To return back to the main screen, click on the <em>Hardware</em> menu and select <em>Shake Gesture</em>. Pat yourself on the back, you&#8217;ve made your first Ogre iPhone application. Our last task for this tutorial will be to modify the Xcode iPhone project template so we can have a basic framework available for when we want to start new Ogre SDK projects for the iPhone iOS platform.</p>
<p>Note: What we have done is build the iPhone project so it works on the iOS Simulator. If you try to deploy to an actual iPhone device, you&#8217;ll receive an error message <em>[Code Sign error: The identity 'iPhone Developer' doesn't match any valid certificate/private key pair in the default keychain]</em>. Deploying your app(s) to an iPhone requires signing up for the <a title="Click to visit Apple iOS Developer Program" href="http://developer.apple.com/programs/ios/" target="_blank">Apple iOS Developer Program</a> which costs $99/yr. The alternative would be to jail-break our iPhone, but I wouldn&#8217;t recommend that. I don&#8217;t have an iPhone so I won&#8217;t be able to go into the details of deploying to a physical device, however there are plenty of resources on the Internet that explain the steps. If I do get an iPhone in the future, I&#8217;ll revisit this topic and post a follow-up tutorial.</p>
<p><strong>Step 4 &#8211; Install &amp; Edit the Ogre Xcode Project Template for iPhone iOS</strong></p>
<p>If you followed my tutorial for the Ogre SDK on Mac OS X then you&#8217;ll already have the Ogre Xcode Templates installed and can skip the next two paragraphs. To install the Xcode templates, you&#8217;ll need to download and install a package found on SourceForge.</p>
<p>Download the <a href="http://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.7/Ogre_Xcode_Templates_20101211.pkg.zip/download">Ogre_Xcode_Templates_20101211.pkg.zip</a> file to your Desktop or some other location on your Mac, extract the Ogre Xcode Templates Package from the zip file, and launch the installer by <em>double-clicking</em> on the package.</p>
<p>On Step 5 of the installer you’ll be asked for the paths to the OSX and iOS Ogre SDK locations. Ignore the OS X portion of the screen and choose the <em>Find Ogre</em> button for the iPhone option. Point to the /OgreSDK_iOS path (or to the location where you decided to install the Ogre SDK for iPhone). Finish the installation by clicking <em>Continue</em> and finally <em>Close</em>.</p>
<p>To edit the Ogre iPhone Xcode template, we need to modify the file project.pbxproj. We&#8217;ll need root privileges to do this so we&#8217;ll need sudo and it&#8217;ll be easier to do it through the Terminal using nano rather than the Text Editor. Open a Terminal window (commonly found under Applications -&gt; Utilities). Issue the following commands.</p>
<pre class="code">computer:~ tony$ cd /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Ogre/iPhone\ OS/
computer:~ tony$ cd ___PROJECTNAME___.xcodeproj/
computer:~ tony$ sudo nano project.pbxproj</pre>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_Xcode_Template_iPhone_project.pbxproj_nano.png"><img class="alignleft size-medium wp-image-216" title="MacOSX Ogre Xcode Template iPhone project.pbxproj nano" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_Xcode_Template_iPhone_project.pbxproj_nano-300x180.png" alt="MacOSX Ogre Xcode Template iPhone project.pbxproj nano" width="300" height="180" /></a>There are two changes we&#8217;ll be making to the to the project.pbxproj settings file, just in many different locations. It&#8217;s a good thing nano has search &amp; replace otherwise this could because extremely tedious. To use the search &amp; replace feature,<br />
press ctrl-\ [ Control-Backslash ]</p>
<p>We&#8217;re going to search for the string _OGRESDK_ROOT_ and replace it with the location of where our Ogre iOS SDK is installed (/OgreSDK_iOS). So after pressing <em>ctrl-\</em> [ Control-Backslash ], in the first prompt enter <em>_OGRESDK_ROOT_</em> and press enter, then enter <em>/OgreSDK_iOS</em> (or wherever you put your Ogre iOS SDK) for the second prompt. You can press the &#8216;y&#8217; key (Yes) to replace each instance one at a time or press the &#8216;a&#8217; key (All) to do them all at once. Here are the line numbers that the changes occur on.<br />
[ Lines 43-50, 52-54, 263-272, 276-279, 295-304, 308-311 ]</p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Template_iPhone_OTHER_LDFLAGS_nano.png"><img class="alignright size-medium wp-image-221" title="MacOSX Xcode Template iPhone OTHER_LDFLAGS nano" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Template_iPhone_OTHER_LDFLAGS_nano-300x193.png" alt="MacOSX Xcode Template iPhone OTHER_LDFLAGS nano" width="300" height="193" /></a>Next we need to add a linker flag to both our Debug &amp; Release configurations so after compilation our Ogre iPhone program gets linked against a specific dynamic library (otherwise you&#8217;ll get linker errors for undefined symbols such as &#8220;_inflateInit_&#8221; &#8220;_inflateEnd&#8221; &#8220;_inflate&#8221; and others). Scroll down to line number 323 (you can press ctrl-c [ Control-C ] to determine what line number you&#8217;re on in nano).</p>
<p>Add a new line and enter the text <em>OTHER_LDFLAGS = /usr/lib/libz.dylib;</em> then scroll to line number 335 and a new line and enter that same text again. You can see how the changes look in the screenshot to the right. Save the Ogre Xcode Template project.pbxproj settings file by pressing ctrl-o [ Control-O ]. Exit with ctrl-x [ Control-X ].</p>
<p><strong>Step 5 &#8211; Build &amp; Run a Demo Project from the Ogre Xcode iPhone Template</strong></p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_iPhone_Template_Project_Demo.png"><img class="alignleft size-medium wp-image-225" title="MacOSX Xcode Ogre iPhone Template Project Demo" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_iPhone_Template_Project_Demo-300x217.png" alt="MacOSX Xcode Ogre iPhone Template Project Demo" width="240" height="174" /></a>The end of this Ogre iPhone SDK tutorial is here. There&#8217;s just one last thing to do &#8211; build and run a demo from our Xcode iPhone template. Open Xcode and create a new project, choose <em>Ogre</em> under User Templates, and click on the <em>iPhone OS</em> option. Click the <em>Choose</em> button and give your project a name (e.g. OgreDemo_iPhone). Click the <em>Build and Run</em> button from the toolbar or use the <em>Build</em> menu if you prefer.</p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_Xcode_iPhone_Demo_iOS_Simulator.png"><img class="alignright size-medium wp-image-226" title="MacOSX Ogre Xcode iPhone Demo iOS Simulator" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Ogre_Xcode_iPhone_Demo_iOS_Simulator-300x159.png" alt="MacOSX Ogre Xcode iPhone Demo iOS Simulator" width="300" height="159" /></a>If all goes well (which it should) your demo project from the Xcode iPhone template will be running in the iOS iPhone Simulator (as can be seen to the right). It&#8217;ll look exactly like the demo project as found in the Mac OS X version (a Green Ogre Head enclosed by the Space Skybox). You can rotate the camera view by click-holding down your mouse on the screen and moving it around. Good job! You&#8217;ve built an Ogre iPhone application and viewed it in the iOS Simulator.</p>
<p>In conclusion, you&#8217;ve learned how to install the Ogre 1.7.3 SDK for iPhone on Mac OSX and built the Samples Browser that comes with the SDK by using CMake. Expanding upon that you also learned how to install the Ogre Xcode Templates, tweaked the iPhone settings file for your development machine, and built a demo project from that iPhone OS version. Now that you&#8217;re familiar with setting up Ogre on a Mac the next thing would be to learn how to make some custom Ogre apps. I recommend checking out the <a title="Click to visit Ogre3D Tutorials Website" href="http://www.ogre3d.org/tikiwiki/Tutorials" target="_blank">tutorials on the Ogre3D website</a> since you now have a working Ogre development environment.</p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D179&count=vertical&related=&text=Ogre3D%20SDK%201.7.3%20for%20Apple%20iPhone%20iOS%20HOWTO' class='twitter-share-button' data-text='Ogre3D SDK 1.7.3 for Apple iPhone iOS HOWTO' data-url='http://www.tonybhimani.com/?p=179' data-counturl='http://www.tonybhimani.com/2011/07/09/ogre3d-sdk-1-7-3-for-apple-iphone-ios-howto/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/07/09/ogre3d-sdk-1-7-3-for-apple-iphone-ios-howto/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/07/09/ogre3d-sdk-1-7-3-for-apple-iphone-ios-howto/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building the Ogre3D SDK Samples on Mac OS X</title>
		<link>http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/</link>
		<comments>http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 06:37:22 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[3D Graphics]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Ogre3D]]></category>
		<category><![CDATA[CMake]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Ogre Samples]]></category>
		<category><![CDATA[Samples Browser]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=148</guid>
		<description><![CDATA[In my previous Ogre3D tutorial for the Mac I showed you how to set up your Mac OSX development environment with the Ogre SDK 1.7.3, install the Xcode templates, and create a sample Ogre project. That&#8217;s a great start but &#8230; <a href="http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In my previous Ogre3D tutorial for the Mac I showed you how to set up your Mac OSX development environment with the Ogre SDK 1.7.3, install the Xcode templates, and create a sample Ogre project. That&#8217;s a great start but what if you wanted to build the samples that came with the Ogre SDK? If you try and use the default Xcode project you&#8217;ll receive build errors. To remedy this we have to install a new application called CMake.</p>
<p><strong>Step 1 &#8211; Install CMake 2.8.3</strong></p>
<p>The Ogre SDK framework makes use of CMake for creating build scripts (or projects) for the chosen target platform. If you were to build the Ogre3D render engine from source, you&#8217;d use CMake to generate a project for Xcode or a Unix Makefile. For building the SDK samples that come with Ogre, it&#8217;s the same process in using CMake to generate a working Xcode project to build those samples. To sum it up, we need CMake.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/MacOSX_CMake_2.8.3_Window.png"><img class="alignleft size-medium wp-image-150" title="MacOSX CMake 2.8.3 Window" src="http://www.tonybhimani.com/files/2011/06/MacOSX_CMake_2.8.3_Window-300x278.png" alt="MacOSX CMake 2.8.3 Window" width="300" height="278" /></a>To <a title="Click to download CMake 2.8.3" href="http://www.cmake.org/files/v2.8/cmake-2.8.3-Darwin-universal.dmg" target="_blank">download CMake 2.8.3</a> you can click that link you just read over. It&#8217;s a Mac DMG disk image. Save it to your Desktop or another location of your choice. Launch the DMG by double-clicking it. Follow the instructions and install CMake to your Mac computer. Check your Applications folder. You should now have CMake 2.8-3 icon. Launch CMake. The User Interface (UI) is to the point (set the source code location, where to build the binaries, and configure the name/value pairs, then build). Next we generate a new Xcode project for the Ogre SDK Samples.</p>
<p><strong>Step 2 &#8211; Generate a New Ogre SDK Samples Xcode Project</strong></p>
<p>You&#8217;ll need to know where you installed your copy of the Ogre SDK to. Mine is located in the root /OgreSDK. Follow the steps below to generate a new Xcode Project for the Ogre SDK Samples.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/MacOSX_CMake_OgreSDK_Samples_Project.png"><img class="alignleft size-medium wp-image-161" title="MacOSX CMake OgreSDK Samples Project" src="http://www.tonybhimani.com/files/2011/06/MacOSX_CMake_OgreSDK_Samples_Project-300x278.png" alt="MacOSX CMake OgreSDK Samples Project" width="300" height="278" /></a></p>
<ol>
<li>Click the <em>Browse Source</em> button and browse to the location of your Ogre SDK installation (/OgreSDK).</li>
<li>Click the <em>Browse Build</em> button and choose a location where you&#8217;d like the build binaries to be saved to. I use the same location as my SDK install (/OgreSDK).</li>
<li>Click on the Configure button. Another window will popup asking for what type of project generator (Xcode) and compilers (Use default native compilers) to use.</li>
<li>CMake will run through the motions and show some Ogre SDK build variables in red. Click the <em>Configure</em> button one more time. After another set of motions you&#8217;ll see more concrete CMake variables.</li>
<li>Click the CMake <em>Generate</em> button to create the Xcode project for building the Ogre SDK Samples. That&#8217;s it for CMake. You can close it now.</li>
</ol>
<p><strong>Step 3 &#8211; Modify Settings in the Ogre3D SDK Samples Project</strong></p>
<p>Before we can build the Ogre Samples we need to make a few modifications to our Xcode Ogre Project. Inside /OgreSDK there is a Xcode project called OGRE.xcodeproj. Double-click the Ogre project to launch Xcode. Go ahead and start the build process. You&#8217;ll encounter hundreds (if not thousands) of errors. To correct this issue we need to change the build architecture to i386. The Ogre.framework SDK we&#8217;re using is prebuilt for i386 so building for any other architecture will fail (unless you build from the source code). Okay, so let&#8217;s make the needed changes so we can compile the Ogre Samples.</p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Edit_Active_Target_Archs.png"><img class="alignleft size-medium wp-image-168" title="MacOSX Xcode Edit Active Target Archs" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Edit_Active_Target_Archs-300x225.png" alt="MacOSX Xcode Edit Active Target Archs" width="300" height="225" /></a>In Xcode, click on the <em>Project</em> menu, select <em>Edit Active Target &#8220;ALL_BUILD&#8221;</em>, a dialog window will appear. Make sure you&#8217;re on the <em>Build</em> tab and that the Configuration is <em>All Configurations</em> and Show is <em>All Settings</em>. Under the <em>User-Defined</em> Settings, the first property is <em>ARCHS</em>. Double-click and edit the value <em>$(ARCHS_STANDARD_32_BIT)</em>. i.e. Take the _64 out of the property value. Save the change and exit the Info window.</p>
<p><a href="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Edit_Project_Settings.png"><img class="alignright size-medium wp-image-170" title="MacOSX Xcode Edit Project Settings" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_Edit_Project_Settings-300x226.png" alt="MacOSX Xcode Edit Project Settings" width="300" height="226" /></a>Next, click on the <em>Project</em> menu and select <em>Edit Project Settings</em>, the Project Info window appears. Make sure you&#8217;re on the <em>Build</em> tab and that the Configuration is <em>All Configurations</em> and Show is <em>All Settings</em>. Under <em>Architecture</em> Settings, the second option Architecture, set the property value to <em>32-bit Universal</em>. Remove all the other architectures except <em>i386</em> for the <em>Valid Architectures</em> property. You can now close the Project Info window.</p>
<p><strong>Step 4 &#8211; Compile the Ogre3D SDK Samples Project in Xcode</strong></p>
<p><img class="alignleft size-medium wp-image-172" title="MacOSX Xcode OGRE Samples Browser Project" src="http://www.tonybhimani.com/files/2011/07/MacOSX_Xcode_OGRE_Samples_Browser_Project-300x237.png" alt="MacOSX Xcode OGRE Samples Browser Project" width="300" height="237" /></p>
<p>At last, the final step, which is the easiest. Build the Ogre project! Click the <em>Build and Run</em> toolbar button or select it from the <em>Build</em> menu. There are 34 samples to compile so the Ogre Samples Xcode Project will take some time to build. If all goes well (which it should) you&#8217;ll have the Ogre Samples running. Explore the Ogre samples. If you encountered compile errors, double-check your project settings.<a href="http://www.tonybhimani.com/files/2011/07/MacOSX_OGRE_Samples_Browser_Penguin.png"><img class="alignright size-medium wp-image-173" title="MacOSX OGRE Samples Browser Penguin" src="http://www.tonybhimani.com/files/2011/07/MacOSX_OGRE_Samples_Browser_Penguin-300x239.png" alt="MacOSX OGRE Samples Browser Penguin" width="300" height="239" /></a></p>
<p>Say Hello to the Penguin from one of the Ogre Samples Browser. There are 33 more to check out, everything from BSP Scenes, to Shadows, to Skydomes, and more.</p>
<p>More Ogre3D guides to read:</p>
<p><a title="Click to visit Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)" href="http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/">Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)</a></p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D148&count=vertical&related=&text=Building%20the%20Ogre3D%20SDK%20Samples%20on%20Mac%20OS%20X' class='twitter-share-button' data-text='Building the Ogre3D SDK Samples on Mac OS X' data-url='http://www.tonybhimani.com/?p=148' data-counturl='http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/07/05/building-the-ogre3d-sdk-samples-on-macosx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)</title>
		<link>http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/</link>
		<comments>http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 01:20:12 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[3D Graphics]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Ogre3D]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=45</guid>
		<description><![CDATA[This guide serves as an introduction to getting started with Ogre3D on Mac OS X, namely setting up the development environment and building a basic application. It&#8217;ll serve as the first in several series of blog posts I intend to &#8230; <a href="http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This guide serves as an introduction to getting started with Ogre3D on Mac OS X, namely setting up the development environment and building a basic application. It&#8217;ll serve as the first in several series of blog posts I intend to write on the subject. Let me say this first. I am not an expert on Ogre, 3D graphics development or theory, or Macs. I may get the jargon wrong and my instructions may not work for very system, so contacting me for help may not the best thing to do, however I&#8217;ll do what I can to assist if you do.</p>
<p>There is a lot of information on Ogre in general on the Internet, but not too much on configuring it on Mac or Linux. I will write a document for installing Ogre on Linux at a later date, but for now it&#8217;s OSX time. Also, you should definitely visit the <a title="Ogre3D Wiki Site" href="http://www.ogre3d.org/tikiwiki/" target="_blank">Ogre Wiki</a> after reading this tutorial for even more information.</p>
<p><strong>Step 1 &#8211; Download &amp; Install Apple Xcode IDE</strong></p>
<p>To get started, you should first get the Xcode IDE if you don&#8217;t already have it. Apple makes it available as a free download after you create an account on their website (the 3.x version is free at the time of this writing). Visit the <a title="Apple Developer - Technologies" href="http://developer.apple.com/technologies/" target="_blank">Apple Developer Website</a> to download a copy of the Xcode 3 IDE. After you download Xcode, then install it. I&#8217;m not going into detail for this step as it&#8217;s very straightforward to install the Xcode IDE.</p>
<p><strong>Step 2 &#8211; Download &amp; Install NVIDIA Cg Toolkit</strong></p>
<p>The NVIDIA CG Toolkit isn&#8217;t required but is needed for the Ogre Cg Program Manager. To install the toolkit, you&#8217;ll need to go to the NVIDIA developer website, create a login if you don&#8217;t already have one, then download the Mac OS X DMG image. To do this, visit the <a title="NVIDIA Developer Cg Toolkit Page" href="http://developer.nvidia.com/cg-toolkit" target="_blank">NVIDIA Developer Cg Toolkit Page</a> and scroll to the bottom of the page. Click on the <em><a title="Click to download NVIDIA Cg Toolkit Download" href="http://developer.nvidia.com/cg-toolkit-download" target="_blank">download</a></em> link. On the Access Denied page, click on the <em>Login</em> link. Proceed to create an account by clicking on the <em>Create new account</em> tab. Go back to the download page and fetch the Mac OS X file image. Install the NVIDIA Cg Toolkit it like you would any other Mac setup package.</p>
<p><strong>Step 3 &#8211; Download &amp; Install Ogre SDK 1.7.3 &amp; OSX Dependencies</strong></p>
<p>At the time of this article the current version of Ogre3D is 1.7.3. To keep things simple we&#8217;ll be installing the prebuilt release of Ogre SDK for OS X instead of compiling from source. To get started, we have to visit the Ogre3D website and download the <a title="Ogre 1.7.3 SDK for Mac OS X" href="http://www.ogre3d.org/download/sdk" target="_blank">Ogre 1.7.3 SDK for Mac OS X</a>. On that page there is a link to the latest Mac OS X Ogre3D release. Download the Ogre SDK to your computer (it&#8217;ll be a .DMG Apple Disk Image File). Double-click the Ogre SDK DMG to mount the disk image.<a href="http://www.tonybhimani.com/files/2011/06/Ogre3D_1.7.3_SDK_for_Mac_OS_X.png"><img class="alignleft size-medium wp-image-62" title="Ogre3D 1.7.3 SDK for Mac OS X window" src="http://www.tonybhimani.com/files/2011/06/Ogre3D_1.7.3_SDK_for_Mac_OS_X-300x258.png" alt="Ogre3D 1.7.3 SDK for Mac OS X window" width="300" height="258" /></a></p>
<p>You&#8217;ll be greeted with an Ogre SDK window (as shown on the left). There is a blue folder called OgreSDK in that window, <em>ctrl-click</em> (aka right-click) on that folder and select the <em>Copy &#8220;OgreSDK&#8221;</em> menu option. Paste the folder to your hard drive (I recommend the root, that being /OgreSDK). Open a Finder window, select your hard drive under Devices, <em>ctrl-click</em> and Paste the OgreSDK folder.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/Copy_OgreSDK_folder_to_hard_drive.png"><img class="alignright size-medium wp-image-66" title="Copy OgreSDK folder to hard drive" src="http://www.tonybhimani.com/files/2011/06/Copy_OgreSDK_folder_to_hard_drive-300x170.png" alt="Copy OgreSDK folder to hard drive" width="300" height="170" /></a>As you can see from the image to the right, the OgreSDK folder is quite large so the copy process may take a moment. When it&#8217;s done we move on to the next step, that being installing the Ogre dependency files. There is a zip file containing dependencies we&#8217;ll need to be able to build our own Ogre Mac OSX applications, and these dependencies are boost, FreeImage, freetype, OIS, and zzip.</p>
<p>The <a title="Ogre Mac OSX Dependencies on SourceForge" href="http://sourceforge.net/projects/ogre/files/" target="_blank">Ogre Mac OSX dependencies</a> zip file is located on SourceForge. When you get there, follow the <em>ogre-dependencies-mac -&gt; 1.7</em> folder path. Download the file <a title="Click to download OgreDependencies_OSX_20110208.zip" href="http://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.7/OgreDependencies_OSX_20110208.zip/download" target="_blank">OgreDependencies_OSX_20110208.zip</a> and extract its contents. You&#8217;ll get a folder called Dependencies. Move that folder into the /OgreSDK folder (or wherever you put yours).</p>
<p><strong>Step 4 &#8211; Download &amp; Install Ogre Xcode Templates</strong></p>
<p>Xcode templates are available for creating minimal Ogre3D Mac Projects. The <a href="https://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.7/OgreDependencies_OSX_20110208.zip/download">Mac OS X Universal Precompiled Dependencies </a>for OSX and iOS can be found of the SourceForge website. There are two installer versions available: the one that has Ogre templates for Xcode 3 and the other for Xcode 4. My directions are made for Xcode 3 so that is the Ogre template installer I&#8217;ll be using. I can&#8217;t tell you if my directions will work for Xcode 4 since I don&#8217;t have it to test against.<br />
<a href="http://www.tonybhimani.com/files/2011/06/Ogre_Xcode_Templates_Installer.png"><img class="alignright size-medium wp-image-87" title="Ogre Xcode Templates Installer" src="http://www.tonybhimani.com/files/2011/06/Ogre_Xcode_Templates_Installer-300x222.png" alt="Ogre Xcode Templates Installer" width="270" height="200" /></a></p>
<p>Okay, so first thing is to download the Ogre Xcode template installer package. Visit the <a title="Ogre SourceForge Files Site" href="https://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.7/" target="_blank">Ogre SourceForge Files</a> website. Download the <a title="Click to download Ogre_Xcode_Templates_20101211.pkg.zip" href="http://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.7/Ogre_Xcode_Templates_20101211.pkg.zip/download" target="_blank">Ogre_Xcode_Templates_20101211.pkg.zip</a> file to your Desktop or some other location on your Mac, extract the Ogre Xcode Templates Package from the zip file, and launch the installer by <em>double-clicking</em> on the package.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/Select_Ogre_Install_Location.png"><img class="size-medium wp-image-94 alignleft" title="Select Ogre Install Location" src="http://www.tonybhimani.com/files/2011/06/Select_Ogre_Install_Location-300x222.png" alt="Select Ogre Install Location" width="270" height="200" /></a>On Step 5 of the installer you&#8217;ll be asked for the paths to the OSX and iOS Ogre SDK locations. I haven&#8217;t discussed the iOS iPhone SDK release of Ogre and we&#8217;ve only installed the OSX version, so for now choose the <em>Find Ogre</em> button for the OSX option. Point to the /OgreSDK path (or to the location where you decided to install the Ogre SDK). Wrap up the rest of the installation by clicking <em>Continue</em> and finally <em>Close</em>.</p>
<p><strong>Step 5 &#8211; Create a Mac OSX Ogre Project From The Xcode Template</strong></p>
<p>Fire up Xcode and create a new Ogre3D project. You&#8217;ll notice on the left side there is now an Ogre section under User Templates. Click on Ogre and there are two template to choose from: iPhone OS and Mac OS X. I&#8217;m going to save the iPhone stuff for my next Ogre tutorial, so for now pick Mac OS X and click the <em>Choose</em> button. When the Xcode popup dialog appears point it to the location where you&#8217;d like to save your Ogre project and give it a name (e.g. <em>OgreDemo</em>).<br />
<a href="http://www.tonybhimani.com/files/2011/06/Ogre_Demo_Xcode_Project.png"><img class="alignleft size-medium wp-image-101" title="Ogre Demo Xcode Project" src="http://www.tonybhimani.com/files/2011/06/Ogre_Demo_Xcode_Project-300x220.png" alt="Ogre Demo Xcode Project" width="300" height="220" /></a></p>
<p>You should now be looking at your Ogre Xcode Project. You may notice that there is some text in red (it indicates a problem). Basically, these files are broken, the paths don&#8217;t resolve. This is caused by a bug in the Ogre Xcode Templates. Step 6 below will resolve this issue. If you attempt to build the project, you&#8217;ll receive over 200 errors.</p>
<p>I recommend you familiarize with Xcode if you&#8217;ve never used it before. You can find documentation on the Apple Developer Website.  Follow this link for the User Guide &#8211; <a title="Xcode 4 User Guide: About Xcode 4" href="http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Introduction/Introduction.html" target="_blank">Xcode 4 User Guide: About Xcode 4</a>.</p>
<p><strong>Step 6 &#8211; Resolving the Ogre Xcode Template Bugs</strong></p>
<p>This next phase deals with fixing some bugs that exist within the Ogre Xcode Templates. What we need to do is correct some Framework and .dylib paths, change the Mac Base SDK, Xcode project format, GCC compiler version, alter the header and library search paths, and make these changes permanent for future projects. Let&#8217;s get started.</p>
<p>1) Correct the Framework and .dylib paths &#8211; We&#8217;ll start with Cg.framework. <em>Ctrl-click</em> it and select <em>Get Info</em>. When the info box displays you&#8217;ll see the path is red. There is a <em>Choose</em> button to the far right of the window, click that and navigate to this file system path /<em>Library/Frameworks</em> and select <em>Cg.framework</em> then click the <em>Choose</em> button. On the info screen the path is now black. Hit the close button in the upper left of the window.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/Cg.framework_Info_Window.png"><img class="alignnone size-medium wp-image-109" title="Cg.framework Info Window" src="http://www.tonybhimani.com/files/2011/06/Cg.framework_Info_Window-300x212.png" alt="Cg.framework Info Window" width="300" height="212" /></a> <a href="http://www.tonybhimani.com/files/2011/06/Cg.framework_Info_Window_Details.png"><img class="size-medium wp-image-110 alignnone" title="Cg.framework Info Window Details" src="http://www.tonybhimani.com/files/2011/06/Cg.framework_Info_Window_Details-300x252.png" alt="Cg.framework Info Window Details" width="240" height="202" /></a></p>
<p>Follow this same procedure for the following files:</p>
<ul>
<li><span style="font-size: 10pt;"><em>Ogre.framework &#8211; /OgreSDK/lib/release/Ogre.framework</em></span></li>
<li><span style="font-size: 10pt;"><em>libOIS.a &#8211;  /OgreSDK/lib/release/libOIS.a</em></span></li>
<li><span style="font-size: 10pt;"><em>Plugin_CgProgramManager.dylib &#8211; /OgreSDK/lib/Plugin_CgProgramManager.dylib</em></span></li>
<li><span style="font-size: 10pt;"><em>Plugin_OctreeSceneManager.dylib &#8211; /OgreSDK/lib/Plugin_OctreeSceneManager.dylib</em></span></li>
<li><span style="font-size: 10pt;"><em>RenderSystem_GL.dylib &#8211; /OgreSDK/lib/RenderSystem_GL.dylib</em></span></li>
</ul>
<p>2) Change the Mac Base SDK, Xcode project format, and GCC compiler version &#8211; Go to the <em>Project</em> menu and select <em>Edit Project Settings</em> option. On the info screen&#8217;s General tab, change the Xcode Project Format to <em>Xcode 3.1-compatible</em> and Base SDK for All Configurations to <em>Mac OS X 10.6</em>. Click on the <em>Build</em> tab, <em>All Configurations</em>, scroll down to the <em>Compiler Version</em> section, and for <em>C/C++ Compiler Version</em> change the value to <em>System default (GCC 4.2)</em>. Close the info window.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/Project_OgreDemo_Info_General.png"><img class="alignnone size-medium wp-image-117" title="Project OgreDemo Info General" src="http://www.tonybhimani.com/files/2011/06/Project_OgreDemo_Info_General-300x256.png" alt="Project OgreDemo Info General" width="300" height="256" /></a><a href="http://www.tonybhimani.com/files/2011/06/Project_OgreDemo_Info_Build.png"><img class="alignnone size-medium wp-image-118" title="Project OgreDemo Info Build" src="http://www.tonybhimani.com/files/2011/06/Project_OgreDemo_Info_Build-300x256.png" alt="Project OgreDemo Info Build" width="300" height="256" /></a></p>
<p>3) Alter the Header and Library Search Paths &#8211; Go back to the <em>Project</em> menu and select the <em>Edit Active Target &#8220;Project Name&#8221;</em> option (Project Name will be what you chose to name your project when you created it). Click on the <em>Build</em> tab, <em>All Configurations</em>, and scroll down to the <em>Search Paths</em> section. There are three lines we&#8217;re interested in: Framework Search Paths, Header Search Paths, and Library Search Paths. You&#8217;ll see that the paths prefix with _OGRESDK_ROOT_. This was supposed to be replaced with the Ogre SDK install location (aka /OgreSDK) you selected during the Xcode Template installation. To correct this we&#8217;ll edit each entry and replace _OGRESDK_ROOT_ with /OgreSDK. Close the window when you&#8217;re done.</p>
<p>Amendment &#8211; July 4, 2011</p>
<p>Change the boost headers directory from <em>boost_1_42</em> to <em>boost_1_46_1 </em>in the header Search Paths. Thanks to Guido for pointing this out.</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/Target_OgreDemo_Info_Build_Before.png"><img class="alignnone size-medium wp-image-122" title="Target OgreDemo Info Build Before" src="http://www.tonybhimani.com/files/2011/06/Target_OgreDemo_Info_Build_Before-300x256.png" alt="Target OgreDemo Info Build Before" width="300" height="256" /></a><a href="http://www.tonybhimani.com/files/2011/06/Target_OgreDemo_Info_Build_After.png"><img class="alignnone size-medium wp-image-123" title="Target OgreDemo Info Build After" src="http://www.tonybhimani.com/files/2011/06/Target_OgreDemo_Info_Build_After-300x256.png" alt="Target OgreDemo Info Build After" width="300" height="256" /></a></p>
<p>That&#8217;s it for the changes. Build your project (<em>Build</em> menu -&gt; <em>Build and Run</em> option). You shouldn&#8217;t receive any build errors (if you did, check all the setting changes from above and make sure you didn&#8217;t miss something). When the demo launches there will be a settings window, accept the defaults and click the OK button. Tada! It&#8217;s an Ogre!</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/Ogre_MacOSX_Demo_Project_Window.png"><img class="alignnone size-medium wp-image-124" title="Ogre MacOSX Demo Project Window" src="http://www.tonybhimani.com/files/2011/06/Ogre_MacOSX_Demo_Project_Window-300x233.png" alt="Ogre MacOSX Demo Project Window" width="300" height="233" /></a></p>
<p>Press the Escape key to exit the Ogre3D program. There is still one last thing to do.</p>
<p>4) Make the Changes Permanent for Future Projects &#8211; The changes we&#8217;ve made are for this project only, so how do we apply them to any future projects created from the Ogre Xcode template? Luckily the solution is rather simple. Our modified project contains a settings file called project.pbxproj that holds the paths of all the frameworks, headers, libraries, and etc we applied as well as more information that isn&#8217;t relevant to our topic. <del>All we have to do is copy the project.pbxproj file and overwrite the version that came with the Ogre Xcode Templates.</del></p>
<p><del>Open your Ogre project folder. Inside there is an item called <em>PROJECT.xcodeproj</em> (where PROJECT is the name of the project you created). <em>Ctrl-click</em> the xcodeproj and select <em>Show Package Contents</em>. Next copy the project.pbxproj file (ctrl-click, copy) and open a new Finder window. Navigate to the Ogre Xcode Templates file system path shown below.</del></p>
<p><del><span style="font-size: 10pt;"><em>/Library/Application Support/Developer/Shared/Xcode/Project Templates/Ogre/Mac OS X</em></span></del></p>
<p><em><a href="http://www.tonybhimani.com/files/2011/06/MacOSX_Finder_Window_Ogre_Xcode_Template_File_System_Path.png"><img class="alignleft size-medium wp-image-132" title="MacOSX Finder Window Ogre Xcode Template File System Path" src="http://www.tonybhimani.com/files/2011/06/MacOSX_Finder_Window_Ogre_Xcode_Template_File_System_Path-300x204.png" alt="MacOSX Finder Window Ogre Xcode Template File System Path" width="300" height="204" /></a></em><br />
<del>Here you&#8217;ll find the project template files that Xcode uses to create your Ogre3D projects. Move into the xcodeproj folder (ctrl-click, Show Package Contents) and paste the project.pbxproj you copied earlier. Replace the existing version. Technically we are done but we should change the file&#8217;s permissions to match.</del></p>
<p><a href="http://www.tonybhimani.com/files/2011/06/MacOSX_Terminal_project.pbxproj_Chown_Permissions.png"><img class="alignright size-medium wp-image-133" title="MacOSX Terminal project.pbxproj Chown Permissions" src="http://www.tonybhimani.com/files/2011/06/MacOSX_Terminal_project.pbxproj_Chown_Permissions-300x188.png" alt="MacOSX Terminal project.pbxproj Chown Permissions" width="300" height="188" /></a><br />
<del>Open a Terminal window (Applications -&gt; Utilities -&gt; Terminal). Navigate to the same Ogre Xcode Templates path from above. Change ownership of the project.pbxproj using the chown command. The full list of commands are show in the image.</del></p>
<pre class="code"><del>computer:~ tony$ cd /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Ogre/Mac\ OS\ X/
computer:~ tony$ cd ___PROJECTNAME___.xcodeproj/
computer:~ tony$ sudo chown root:admin project.pbxproj</del></pre>
<p>Amendment &#8211; July 4, 2011</p>
<p>In my haste of making this tutorial I didn&#8217;t completely test every aspect. The stricken out text above was for copying the OgreDemo project&#8217;s project.pbxproj settings file on top of the Ogre Xcode Project template&#8217;s version. The problem is that some settings then become hard-coded to use a file name of OgreDemo and the project won&#8217;t build unless it has the same exact name. Obviously that won&#8217;t work. You could rename but that defeats the purpose of a template. So we&#8217;ll be making modifications to the Ogre Xcode project template project.pbxproj directly this time around. We&#8217;re also going to bypass the copy, paste, ownership stuff, and use nano for editing to make the changes. Open a Terminal and issue the commands below.</p>
<pre class="code">computer:~ tony$ cd /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Ogre/Mac\ OS\ X/
computer:~ tony$ cd ___PROJECTNAME___.xcodeproj/
computer:~ tony$ sudo nano project.pbxproj</pre>
<p>Make the following changes to the Ogre Xcode Template project.pbxproj settings file. I&#8217;ve included the line numbers for your information. To see what line number you&#8217;re on in nano, press ctrl-c. [ Control-C ]</p>
<p><a href="http://www.tonybhimani.com/files/2011/06/MacOSX_Ogre_Xcode_Template_project.pbxproj_nano.png"><img class="alignleft size-medium wp-image-164" title="MacOSX Ogre Xcode Template project.pbxproj nano" src="http://www.tonybhimani.com/files/2011/06/MacOSX_Ogre_Xcode_Template_project.pbxproj_nano-300x183.png" alt="MacOSX Ogre Xcode Template project.pbxproj nano" width="210" height="128" /></a></p>
<p><span style="font-family: Georgia, 'Bitstream Charter', serif; line-height: 24px; font-size: 16px;">Replace <em>libois.a</em> with <em>libOIS.a<br />
<span style="font-style: normal;">[ Lines 16, 73, 98, 126 ]</span></em></span></p>
<p><span style="font-family: Georgia, 'Bitstream Charter', serif; line-height: 24px; font-size: 16px;">Replace <em>boost_1_42</em> with <em>boost_1_46_1<br />
</em>[ Lines 311, 342 ] </span></p>
<p><span style="font-family: Georgia, 'Bitstream Charter', serif; line-height: 24px; font-size: 16px;">Replace the path to Cg.framework <em>_OGRESDK_ROOT_/Dependencies</em> with <em>/Library/Frameworks<br />
</em></span>[ Line 71 ]</p>
<p>Replace all <em>_OGRESDK_ROOT_</em> with your Ogre SDK path <em>/OgreSDK<br />
</em>[ Lines 72-73, 76-78, 299-300, 309-312, 318-320, 333-334, 340-343, 349-351 ]</p>
<p>Fix the Build Configurations (Debug &amp; Release)<br />
Change <em>ARCHS = &#8220;$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)&#8221;;</em> to <em>ARCHS = &#8220;$(ARCHS_STANDARD_32_BIT)&#8221;;<br />
</em>Change <em>GCC_VERSION = 4.0;</em> to <em>GCC_VERSION = &#8220;&#8221;;<br />
</em>Change <em>ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = &#8220;$(NATIVE_ARCH)&#8221;;</em> to <em>ONLY_ACTIVE_ARCH = YES;<br />
</em>Change <em>SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;</em> to <em>SDKROOT = /Developer/SDKs/MacOSX10.6.sdk;<br />
</em>[ Lines 360, 363, 366, 368 ] and [ Lines 375, 377, 380, 382 ]</p>
<p>Once you&#8217;ve made all the changes to the Ogre Xcode Template project.pbxproj, save the file by pressing ctrl-o. [ Control-O ] and ctrl-x [ Control-X ] to exit nano. Now any project created from the Ogre Xcode Templates will compile and from any name you save your project as.</p>
<p>That concludes this tutorial on installing the Ogre SDK 1.7.3 on a Mac OS X system. Any future Xcode projects you create using the Ogre Xcode Template won&#8217;t need changes to compile out the door. Stay tuned for more Ogre3D Mac articles from me.</p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D45&count=vertical&related=&text=Guide%20to%20Installing%20Ogre3D%20on%20Mac%20OS%20X%20%28Xcode%20%2B%20Ogre%20SDK%201.7.3%29' class='twitter-share-button' data-text='Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)' data-url='http://www.tonybhimani.com/?p=45' data-counturl='http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/06/25/guide-to-installing-ogre3d-on-macosx-xcode-ogre-sdk-1-7-3/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Proud Owner of a MacBook Pro, Seriously!</title>
		<link>http://www.tonybhimani.com/2011/03/06/proud-owner-of-a-macbook-pro-seriously/</link>
		<comments>http://www.tonybhimani.com/2011/03/06/proud-owner-of-a-macbook-pro-seriously/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 07:28:18 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Apple SDK]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MacBook]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=38</guid>
		<description><![CDATA[The MacBook I&#8217;ve been waiting for has been delivered. Thanks Timo! Tony + Mac = Joke you say? I&#8217;ve never used Macs, not because I don&#8217;t like them, but because I&#8217;ve never had the need for one. The only Mac &#8230; <a href="http://www.tonybhimani.com/2011/03/06/proud-owner-of-a-macbook-pro-seriously/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tonybhimani.com/files/2011/03/macbook.jpg"><img class="alignleft size-medium wp-image-39" title="MacBook Pro" src="http://www.tonybhimani.com/files/2011/03/macbook-300x224.jpg" alt="" width="300" height="224" /></a> The MacBook I&#8217;ve been waiting for has been delivered. Thanks Timo!</p>
<p><strong>Tony + Mac = Joke you say?</strong><br />
I&#8217;ve never used Macs, not because I don&#8217;t like them, but because I&#8217;ve never had the need for one. The only Mac I fiddled with was the one that EarthLink had for tech support calls (iMac I believe &#8211; the triangle shaped TV looking one). The hockey puck shaped mouse was too cute. Anyway, I&#8217;m a Linux guy and using a Mac is well, not too far off I guess &#8211; the ones they make these days that is.</p>
<p><strong>Why do I have a Mac now?</strong><br />
My friend Timo can take all the credit for this since it was his idea. He made a strong suggestion that I get into developing iPhone apps and cash in on the action. I&#8217;d like to think I&#8217;m a capitalist at heart and figured, what the hell, why not. Here&#8217;s the problem, I need to learn the operating system and how to actually do the development part. I&#8217;m not too worried, I mean if I can get a handle on Linux then a Mac shouldn&#8217;t been too difficult. I started absorbing the UI and navigating around earlier. I&#8217;ll play with the OS more after work tomorrow.</p>
<p><strong>Apple SDK (Xcode IDE, et al)</strong><br />
I managed to get the Apple SDK loaded on the MacBook. It took around 30 minutes for it to download (3+ GB SDK, yikes!) and installed in roughly 15 minutes. Hmmm, no easily accessible launcher icon appeared on the desktop or in the Applications menu. I happened to find the SDK in the Developer directory in the root of the hard drive. To make life easier I added Xcode to the Dock. There is a LOT of documentation to read and plenty of sample code to fiddle with and I feel I need to spend a couple days looking it all over before I do anything bold like build an app of my own (and will need idea first).</p>
<p><strong>MacBook hardware is very cool</strong><br />
The first thing I noticed about the MacBook is its AC adapter. The thing reminds me of a universal power plug adapter, with its prongs that flip down and its square white body. Okay, now this is probably the best thing about it, the power connector doesn&#8217;t plug into the Mac, it sits on the side magnetically in a little rectangular groove. Timo called it a break-away connection. This is type of connectivity is extremely useful for people that trip over their (or strangers) PC laptop AC adapter line cord and break the pin it sits over.</p>
<p>The MacBook also has a Firewire connection, DVI video interface, and Webcam. Standard stuff so I&#8217;m not going to say anything more about it.</p>
<p>I&#8217;ll end with this: I like the Mac, it&#8217;s nice. No complaints.</p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D38&count=vertical&related=&text=Proud%20Owner%20of%20a%20MacBook%20Pro%2C%20Seriously%21' class='twitter-share-button' data-text='Proud Owner of a MacBook Pro, Seriously!' data-url='http://www.tonybhimani.com/?p=38' data-counturl='http://www.tonybhimani.com/2011/03/06/proud-owner-of-a-macbook-pro-seriously/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/03/06/proud-owner-of-a-macbook-pro-seriously/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/03/06/proud-owner-of-a-macbook-pro-seriously/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Big Switch to Ubuntu Linux</title>
		<link>http://www.tonybhimani.com/2011/01/30/the-big-switch-to-ubuntu-linux/</link>
		<comments>http://www.tonybhimani.com/2011/01/30/the-big-switch-to-ubuntu-linux/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 09:47:33 +0000</pubDate>
		<dc:creator>Tony Bhimani</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Compiz Fusion]]></category>

		<guid isPermaLink="false">http://www.tonybhimani.com/?p=31</guid>
		<description><![CDATA[For several years I had Windows XP as the operating system on my laptop. It&#8217;s been mostly out of necessity as my laptop is primarily used for work and I&#8217;ve been used to using specific applications for productivity, such as &#8230; <a href="http://www.tonybhimani.com/2011/01/30/the-big-switch-to-ubuntu-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For several years I had Windows XP as the operating system on my laptop. It&#8217;s been mostly out of necessity as my laptop is primarily used for work and I&#8217;ve been used to using specific applications for productivity, such as Dreamweaver for HTML and PHP coding, PuTTY for SSH, WinSCP for SFTP file transfers, TortoiseSVN for source code version control, Paint Shop Pro for graphics editing, OpenVPN GUI for my VPN connection, and Visual Studio for this one Windows program I have to maintain. It&#8217;s always been Windows for desktops and Linux for servers with me, as you can see from all the tutorials I&#8217;ve written on how to make Linux your server platform. In the past I haven&#8217;t had much luck with a Linux desktop. I&#8217;ve gone through old versions SUSE, Fedora, CentOS, and even Ubuntu. Keep in mind all this was going on between 2004 to 2008. Driver support has been an issue as well as functionality, so I have fallen back to Windows quite a few times. As much as I enjoy tweaking stuff to get it to work, it gets old really fast &#8212; ndiswrapper to get my WiFi card working. Come on, seriously?</p>
<p>Moving forward, I wanted to try a Linux desktop again, so on December 31, 2010 I downloaded and burned the Ubuntu 10.10 ISO. With my fingers crossed, I loaded it on a new hard drive (just in case I would have to fall back yet again). From the start it detected my WiFi card and picked up on my network. Ubuntu also gave me my standard 1680&#215;1050 resolution. I was feeling optimistic in that I made the right choice. 10 to 15 minutes later, I had a new operating system. Next came the fun part of learning it.</p>
<p>Okay, so I never use a Linux desktop and I need to try and find equivalents of the applications I used on Windows. I hit up Google and after a little research on each topic I started installing the programs I&#8217;d need to be able to work. This was accomplished using the Ubuntu Software Center. To break it down, these are the apps I needed.</p>
<table border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td></td>
<td><strong>Windows</strong></td>
<td><strong>Ubuntu</strong></td>
</tr>
<tr>
<td><strong>Coding</strong></td>
<td>Dreamweaver</td>
<td>gPHPEdit</td>
</tr>
<tr>
<td><strong>SSH</strong></td>
<td>PuTTY</td>
<td>PuTTY</td>
</tr>
<tr>
<td><strong>SFTP</strong></td>
<td>WinSCP</td>
<td>FileZilla</td>
</tr>
<tr>
<td><strong>Version Control</strong></td>
<td>TortoiseSVN</td>
<td>RabbitVCS</td>
</tr>
<tr>
<td><strong>Graphics</strong></td>
<td>Paint Shop Pro</td>
<td>GIMP</td>
</tr>
<tr>
<td><strong>VPN</strong></td>
<td>OpenVPN GUI</td>
<td>Network Manager OpenVPN</td>
</tr>
<tr>
<td><strong>Web Browser</strong></td>
<td>FireFox</td>
<td>FireFox</td>
</tr>
<tr>
<td><strong>Email</strong></td>
<td>Thunderbird</td>
<td>Evolution / Thunderbird</td>
</tr>
<tr>
<td><strong>Documents</strong></td>
<td>MS Office</td>
<td>OpenOffice</td>
</tr>
</tbody>
</table>
<p>In regards to Visual Studio, I haven&#8217;t tried installing it under WINE to see if it would work. Whenever I get around to doing so, I&#8217;ll share my results.</p>
<p>For the last 30 days I have been using Ubuntu and am loving it. There was a learning curve at first but as with everything, the more you use the faster you adapt. Ubuntu boots and shuts down faster than WinXP. I haven&#8217;t had a single crash or lockup since I started using it. The Compiz Fusion is windows manager is absolutely awesome! I love the 3D desktop eye candy &#8212; burning windows upon exit, rotating cube view with skydome, window wobble, opacify, etc.</p>
<p>For anyone looking to switch to Linux for their desktop operating system, I highly recommend <a title="Ubuntu Download Page" href="http://www.ubuntu.com/desktop/get-ubuntu/download" target="_blank">Ubuntu</a>. I&#8217;ve included a short video of my Ubuntu laptop in action.</p>
<p><object width="425" height="344" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/epEt5yNv42s?hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed width="425" height="344" type="application/x-shockwave-flash" src="http://www.youtube.com/v/epEt5yNv42s?hl=en&amp;fs=1" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<p><div class="gpo_leftcontainer"><div class="gpo_buttons"><g:plusone size="tall" count="true"></g:plusone></div></div> <a href='http://twitter.com/share?url=http%3A%2F%2Fwww.tonybhimani.com%2F%3Fp%3D31&count=vertical&related=&text=The%20Big%20Switch%20to%20Ubuntu%20Linux' class='twitter-share-button' data-text='The Big Switch to Ubuntu Linux' data-url='http://www.tonybhimani.com/?p=31' data-counturl='http://www.tonybhimani.com/2011/01/30/the-big-switch-to-ubuntu-linux/' data-count='vertical' data-via='TonyBhimani'></a> <script type='text/javascript'>
<!--
tweetmeme_source = 'TonyBhimani';
tweetmeme_url = 'http://www.tonybhimani.com/2011/01/30/the-big-switch-to-ubuntu-linux/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybhimani.com/2011/01/30/the-big-switch-to-ubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
