<?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>exploration &#187; openframeworks</title>
	<atom:link href="http://robertcarlsen.net/tag/openframeworks/feed" rel="self" type="application/rss+xml" />
	<link>http://robertcarlsen.net</link>
	<description>accounts of success and misadventure</description>
	<lastBuildDate>Tue, 13 Jul 2010 14:37:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>openFrameworks iPhone 3GS / OS 3.0</title>
		<link>http://robertcarlsen.net/2009/07/14/openframeworks-iphone-3gs-os-3-0-882</link>
		<comments>http://robertcarlsen.net/2009/07/14/openframeworks-iphone-3gs-os-3-0-882#comments</comments>
		<pubDate>Tue, 14 Jul 2009 06:13:31 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/?p=882</guid>
		<description><![CDATA[i&#8217;ve been dealing with a performance bug in a particle + accelerometer oF app. the same project which has run very smoothly on a first generation iPhone with OS 2.2.1 has a noticeable stutter on an iPhone 3GS with OS 3.0.
there was no improvement despite several rounds of optimizing the openGL drawing code and plugging [...]]]></description>
			<content:encoded><![CDATA[<p>i&#8217;ve been dealing with a performance bug in a particle + accelerometer oF app. the same project which has run very smoothly on a first generation iPhone with OS 2.2.1 has a noticeable stutter on an iPhone 3GS with OS 3.0.</p>
<p>there was no improvement despite several rounds of optimizing the openGL drawing code and plugging several memory leaks.</p>
<p>finally, in frustration i bumped the explicit frame rate declaration from the default 60 fps to 120 fps. i realize that ofSetFrameRate(60) is merely the upper limit of the frame rate, and that the hardware won&#8217;t actually go faster than it can handle, however this immediately improved performance on the 3GS and the first gen is about the same as it was. further improvement was had with a declared frame rate of 240 fps.</p>
<p>i haven&#8217;t had a chance to look into the underlying issue, but i believe that oF is using NSTimer under the hood to trigger a scheduled update() and draw(). has there been some change in the SDK there?</p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/07/14/openframeworks-iphone-3gs-os-3-0-882/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(overly simplistic) saving state in oF for iPhone</title>
		<link>http://robertcarlsen.net/2009/06/19/overly-simplistic-saving-state-in-of-for-iphone-847</link>
		<comments>http://robertcarlsen.net/2009/06/19/overly-simplistic-saving-state-in-of-for-iphone-847#comments</comments>
		<pubDate>Fri, 19 Jun 2009 15:52:37 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/?p=847</guid>
		<description><![CDATA[There was a recent comment about saving / restoring application state when using openFrameworks for iPhone which got me to thinking about how to do it. Apple&#8217;s frameworks provide a fairly thorough way to save state to the disk and restore later. There seem to be three primary ways to do this: simple plist files [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/06/save_state2.jpg" rel="lightbox[847]"><img class="alignright size-thumbnail wp-image-854" title="save_state" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/06/save_state2-150x150.jpg" alt="save_state" width="150" height="150" /></a>There was a recent <a href="http://robertcarlsen.net/blog/2009/05/31/using-openframeworks-for-iphone-dev-757#comment-553">comment</a> about saving / restoring application state when using openFrameworks for iPhone which got me to thinking about how to do it. Apple&#8217;s frameworks provide a fairly thorough way to save state to the disk and restore later. There seem to be three primary ways to do this: simple plist files (usually encoded in binary on the iPhone), archived data (they like to refer to this as freeze-dried object graphs) and core data.</p>
<p>I believe that archiving objects require methods inherited from NSObject, which we don&#8217;t have in openFrameworks&#8217; ofSimpleApp. Core Data seems like overkill, so I looked into using plist files.</p>
<p>There are likely better ways to do this, but this ad-hoc solution works wonderfully for a small app I&#8217;m working on, and only requires a bit of Objective-C code that could likely be moved up into a nice wrapper class. However, since the question was asked I&#8217;d just like to get it out there before working on a more elegant approach.<span id="more-847"></span></p>
<p>The easiest way to store state is with NSUserDefaults. The following returns a pointer to the shared user defaults object then writes several values to it. Adding data to the object will get cached in memory and eventually written to disk (or upon receiving a synchronize message). The key is just a NSString, which can be arbitrarily named, but you&#8217;ll need to use identical values to retrieve the data later.</p>
<pre class="brush: cpp; light: true;">
NSUserDefaults *savedData = [NSUserDefaults standardUserDefaults];

[savedData setInteger:score forKey:@&quot;score&quot;];
[savedData setInteger:pointsAvail forKey:@&quot;pointsAvail&quot;];
[savedData setInteger:timeRemaining forKey:@&quot;time&quot;];
[savedData synchronize];
</pre>
<p>The savedData object should be autoreleased. Plists can handle basic data types such as integer, float, bool and double. Look at the documentation for specific messages, but it&#8217;s usually like setFloat:forKey: or setBool:forKey:. It can also handle some NSObjects such as NSString, NSArray and NSDictionary. The selector for those is setObject:forKey:.</p>
<p>Reading back is just as simple. If a key doesn&#8217;t exist 0 is returned for a number, and nil for other strings, arrays and dictionaries. In the below example score, pointsAvail and timeRemaining are instance variables of testApp.</p>
<pre class="brush: cpp; light: true;">
NSUserDefaults *savedData = [NSUserDefaults standardUserDefaults];

score = [savedData integerForKey:@&quot;score&quot;];
pointsAvail = [savedData integerForKey:@&quot;pointsAvail&quot;];
timeRemaining = [savedData integerForKey:@&quot;time&quot;];
</pre>
<p>To get this all working as expected, retrieve the defaults in setup(), and be sure to do some sanity checking if the values aren&#8217;t found (ie. if this is the first run of the app). <strong>Because we&#8217;re mixing Objective-C and C++ in testApp, be sure to rename main.cpp to main.mm, testApp.cpp to testApp.mm and add &#8220;#import &lt;UIKit/UIKit.h&gt;&#8221; to the top of testApp.mm.</strong></p>
<p>A code snippet from setup():</p>
<pre class="brush: cpp; light: true;">
// test for previous state
NSUserDefaults *savedData = [NSUserDefaults standardUserDefaults];
int hideInstructions = [savedData integerForKey:@&quot;hideInstructions&quot;];

// if the key &quot;hideInstructions&quot; doesn't exist, then it will return 0
if(hideInstructions) {
// we've must have run at least once before and written &quot;hideInstructions&quot;
// restoreGame will read in the rest of the saved values:
restoreGame();
} else {
// assume first run
[savedData setInteger:1 forKey:@&quot;hideInstructions&quot;];
showInstructions();
}
</pre>
<p>openFrameworks supports an exit() method which gets called dutifully on the iPhone when the application will quit. This is a fine place to write out data to the userDefaults. The challenge as a programmer will be to determine the appropriate data to save and restore. In my simple game, I needed to save the game state for score and time, but also the position and basic state of the widgets on screen. With a larger game I&#8217;d look into writing methods into my objects cough up their own important data and then request it when the app is exiting. Keep in mind that there is a narrow window of time that the iPhone OS provides between receiving a signal to quit and when it will forcefully quit your app (like a few seconds) so saving data needs to happen quickly.</p>
<p>This method is purposefully rudimentary, but I think it works well for this particular use.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/06/19/overly-simplistic-saving-state-in-of-for-iphone-847/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>openFrameworks knitting circle</title>
		<link>http://robertcarlsen.net/2009/06/10/openframeworks-knitting-circle-785</link>
		<comments>http://robertcarlsen.net/2009/06/10/openframeworks-knitting-circle-785#comments</comments>
		<pubDate>Thu, 11 Jun 2009 02:05:18 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[knitting circle]]></category>
		<category><![CDATA[nyc]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=785</guid>
		<description><![CDATA[Had a really nice time tonight at the oF knitting circle held at Parsons in NYC. Saw several really inspiring projects and spoke to several people about using openFrameworks for iPhone development and showed the current version of the particle game using ofxiPhoneAlertView.
Quite a few folks mentioned that they have become interested in openFrameworks after [...]]]></description>
			<content:encoded><![CDATA[<p>Had a really nice time tonight at the oF knitting circle held at Parsons in NYC. Saw several really inspiring projects and spoke to several people about using openFrameworks for iPhone development and showed the current version of the particle game using <a href="http://robertcarlsen.net/blog/2009/06/10/ofxiphonealertview-780">ofxiPhoneAlertView</a>.</p>
<p>Quite a few folks mentioned that they have become interested in openFrameworks after hearing about it&#8217;s use for creating iPhone applications. While not every app is suitable, I saw a few really nice examples. My only regret is not getting the name of the fellow who was working with creating a sound wrapper.</p>
<p>The wiki page for the knitting circle is at the openFrameworks <a href="http://wiki.openframeworks.cc/index.php?title=OF_knitting_circle_-_Parsons%2C_June_10" onclick="pageTracker._trackPageview('/outgoing/wiki.openframeworks.cc/index.php?title=OF_knitting_circle_-_Parsons_2C_June_10&amp;referer=');">wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/06/10/openframeworks-knitting-circle-785/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ofxiPhoneAlertView</title>
		<link>http://robertcarlsen.net/2009/06/10/ofxiphonealertview-780</link>
		<comments>http://robertcarlsen.net/2009/06/10/ofxiphonealertview-780#comments</comments>
		<pubDate>Wed, 10 Jun 2009 19:48:02 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[wrapper]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=780</guid>
		<description><![CDATA[Here is a (really) basic wrapper for the UIAlertView in openFrameworks of iPhone. Not all of the necessary delegate methods have been implemented yet, but this is enough for me to get the proof of concept rolling in an app I&#8217;m building.
Feel free to let me know how I can do things better, or just [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a (really) basic wrapper for the UIAlertView in openFrameworks of iPhone. Not all of the necessary delegate methods have been implemented yet, but this is enough for me to get the proof of concept rolling in an app I&#8217;m building.</p>
<p>Feel free to let me know how I can do things better, or just tinker with the code directly at github: <a href="http://github.com/rcarlsen/ofxiPhoneWrappers/tree" onclick="pageTracker._trackPageview('/outgoing/github.com/rcarlsen/ofxiPhoneWrappers/tree?referer=');">ofxiPhoneWrappers</a></p>
<p>Check out the <a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/06/alertView.zip">example project</a>. This is a bit of a kludge. I would like to figure out how to avoid having to declare main and testApp as mixed source files (.mm). It works for now, however.</p>
<p>Here are the notes on using the class:<span id="more-780"></span></p>
<pre class="brush: cpp;">
// ofxiPhoneAlertView:
// setup the list of buttons
vector&lt;string&gt; otherButtons;
otherButtons.push_back(&quot;Button 1&quot;);
otherButtons.push_back(&quot;Button 2&quot;);
// the args are: title, message, cancel button title (&quot;&quot; == omitted), vector of other button titles
ofxiPhoneAlertView *alert = new ofxiPhoneAlertView(&quot;Title,&quot;Here is the alert message.&quot;,&quot;&quot;,otherButtons);
// display the alert view
alert-&gt;show();

// I'm using the following methods in update()
// test if the alert is visible (bool):
alert-&gt;isVisible();

// test if the alert has been dismissed:
alert-&gt;isDismissed();

// get the selected button (int):
alert-&gt;getSelectedButton();

// if you use several alerts, you can distinguish between them via their title:
alert-&gt;getTitle();

// example logic:
switch(alert-&gt;getSelectedButton()){
case -1:
// cancel, or no selection
printf(&quot;alert = -1&quot;);
break;
case 0:
// first, non-cancel button
printf(&quot;alert = 0&quot;);
break;
case 1:
// next button. will be the second button after Cancel
printf(&quot;alert = 1, ok&quot;);
break;
}
</pre>
<h3>ofxiPhoneAlertView.h</h3>
<pre class="brush: cpp;">
/*
ofxiPhoneAlertView.h

Created on 6/10/09.
Copyright 2009 Robert Carlsen | robertcarlsen.net

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.

*/

#import &lt;UIKit/UIKit.h&gt;
#import &quot;ofMain.h&quot;

@interface ofxiPhoneAlertViewDelegate : UIAlertView &lt;UIAlertViewDelegate&gt;
{
UIAlertView*			_alertView;
int                     selectedButton;
bool                    dismissed;
}

- (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles;

-(int)getButton;
-(bool)isDismissed;
-(string)getTitle;

@end

class ofxiPhoneAlertView
{
public:
ofxiPhoneAlertView(string title, string message, string cancelButtonTitle, vector&lt;string&gt; otherButtonTitles);
~ofxiPhoneAlertView();

void show();
int getSelectedButton();
bool isVisible();
bool isDismissed();
string getTitle();

protected:
ofxiPhoneAlertViewDelegate *alertViewDelegate;
};
</pre>
<h3>ofxiPhoneAlertView.mm</h3>
<pre class="brush: cpp;">
/*
ofxiPhoneAlertView.mm

Created on 6/10/09.
Copyright 2009 Robert Carlsen | robertcarlsen.net

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
*/

#include &quot;ofxiPhoneAlertView.h&quot;

// c++ class methods
ofxiPhoneAlertView::ofxiPhoneAlertView(string _title,
string _message,
string _cancelButtonTitle,
vector&lt;string&gt; _otherButtonTitles){
NSString * title = [[[NSString alloc] initWithCString: _title.c_str()] autorelease];
NSString * message = [[[NSString alloc] initWithCString: _message.c_str()] autorelease];

// nil value will omit button
NSString * cancelButtonTitle;
if(_cancelButtonTitle == &quot;&quot;)
cancelButtonTitle = nil;
else
cancelButtonTitle = [[[NSString alloc] initWithCString: _cancelButtonTitle.c_str()] autorelease];

// the other buttons are an array of strings
NSMutableArray *otherButtons = [NSMutableArray array];
for(int i=0;i&lt;_otherButtonTitles.size();i++){
[otherButtons addObject:[[[NSString alloc] initWithCString: _otherButtonTitles[i].c_str()] autorelease]];
}

alertViewDelegate = [[ofxiPhoneAlertViewDelegate alloc] initWithTitle:title
message:message
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:otherButtons];

}

ofxiPhoneAlertView::~ofxiPhoneAlertView(){
[alertViewDelegate release];
}

void ofxiPhoneAlertView::show(){
[alertViewDelegate show];
}

int ofxiPhoneAlertView::getSelectedButton(){
return [alertViewDelegate getButton];
}

bool ofxiPhoneAlertView::isVisible(){
return [alertViewDelegate isVisible];
}

bool ofxiPhoneAlertView::isDismissed(){
return [alertViewDelegate isDismissed];
}

string ofxiPhoneAlertView::getTitle(){
return [alertViewDelegate getTitle];
}

// obj-c implementation
@implementation ofxiPhoneAlertViewDelegate

- (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles
{
if (self = [super initWithTitle:title
message:message
delegate:self
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:nil ]){
_alertView = [[ofxiPhoneAlertViewDelegate alloc] initWithTitle:title
message:message
delegate:self
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:nil ];
for(NSString *s in otherButtonTitles){
[_alertView addButtonWithTitle:s];
[self addButtonWithTitle:s];
}

dismissed = false;
//self = [_alertView copy];
}
return self;
}

-(int)getButton{
return selectedButton;
}

-(bool)isDismissed{
return dismissed;
}

-(string)getTitle{
// return the title of the alert. to differentiate between separate alert views
return [[self title] UTF8String];
}

/*
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
{

}
*/
// Called when a button is clicked. The view will be automatically dismissed after this call returns
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
selectedButton = buttonIndex;
dismissed = true;
NSLog(@&quot;Selected button: %d&quot;,selectedButton);
}

/*
// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)alertViewCancel:(UIAlertView *)alertView;

- (void)willPresentAlertView:(UIAlertView *)alertView;  // before animation and showing view
- (void)didPresentAlertView:(UIAlertView *)alertView;  // after animation

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;  // after animation
*/

-(void) dealloc{
[_alertView release];
[super dealloc];
}

@end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/06/10/ofxiphonealertview-780/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BarCampNYC4 presentation</title>
		<link>http://robertcarlsen.net/2009/06/03/barcampnyc4-presentation-773</link>
		<comments>http://robertcarlsen.net/2009/06/03/barcampnyc4-presentation-773#comments</comments>
		<pubDate>Wed, 03 Jun 2009 22:20:57 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[barcamp]]></category>
		<category><![CDATA[itp]]></category>
		<category><![CDATA[nyc]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=773</guid>
		<description><![CDATA[BarCampNYC4 was hosted by ITP on May 30-31st. It was a great event – I&#8217;d highly recommend going to another one.
I did a presentation titled &#8220;Using openFrameworks for iPhone App Development&#8221; which I think went well, although it was quite dense. Can&#8217;t be helped, I suppose. The walk-through of getting set up with openFrameworks has [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://barcamp.org/BarCampNYC4" onclick="pageTracker._trackPageview('/outgoing/barcamp.org/BarCampNYC4?referer=');">BarCampNYC4</a> was hosted by ITP on May 30-31st. It was a great event – I&#8217;d highly recommend going to another one.</p>
<p>I did a presentation titled &#8220;Using openFrameworks for iPhone App Development&#8221; which I think went well, although it was quite dense. Can&#8217;t be helped, I suppose. The walk-through of getting set up with openFrameworks has been <a href="/2009/05/31/using-openframeworks-for-iphone-dev-757">previously posted</a>, and is also available on <a href="http://itpedia.nyu.edu/wiki/OpenFrameworks_for_iPhone" onclick="pageTracker._trackPageview('/outgoing/itpedia.nyu.edu/wiki/OpenFrameworks_for_iPhone?referer=');">ITPedia</a>. Below is an embedded video of the presentation thanks to Mark B&#8230; and <a href="http://nwcny.com/" onclick="pageTracker._trackPageview('/outgoing/nwcny.com/?referer=');">New Work City</a>.<span id="more-773"></span></p>
<div style="position:relative;text-align:center;">
<script src="http://static.livestream.com/scripts/playerv2.js?channel=newworkcity&amp;layout=playerEmbedDefault&amp;backgroundColor= 0xf1f1f1&amp;backgroundAlpha=1&amp;backgroundGradientStrength=0&amp;chromeColor=0x000000&amp;headerBarGlossEnabled=true&amp;controlBarGlossEnabled=true&amp;chatInputGlossEnabled=true&amp;uiWhite=true&amp;uiAlpha=0.5&amp;uiSelectedAlpha=1&amp;dropShadowEnabled=true&amp;dropShadowHorizontalDistance=10&amp;dropShadowVerticalDistance=10&amp;paddingLeft=10&amp;paddingRight=10&amp;paddingTop=10&amp;paddingBottom=10&amp;cornerRadius=10&amp;backToDirectoryURL=null&amp;bannerURL=null&amp;bannerText=null&amp;bannerWidth=320&amp;bannerHeight=50&amp;showViewers=true&amp;embedEnabled=true&amp;chatEnabled=true&amp;onDemandEnabled=true&amp;programGuideEnabled=false&amp;fullScreenEnabled=true&amp;reportAbuseEnabled=false&amp;gridEnabled=false&amp;initialIsOn=false&amp;initialIsMute=false&amp;initialVolume=10&amp;contentId=pla_4584560708901816923&amp;initThumbUrl=http://mogulus-user-files.s3.amazonaws.com/chnewworkcity/2009/05/31/6704e8b1-e227-4c90-a194-035dcb0dbfa0_1050.jpg&amp;playeraspectwidth=16&amp;playeraspectheight=9&amp;mogulusLogoEnabled=true&amp;width=400&amp;height=400&amp;wmode=window" type="text/javascript"></script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/06/03/barcampnyc4-presentation-773/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using openFrameworks for iPhone dev</title>
		<link>http://robertcarlsen.net/2009/05/31/using-openframeworks-for-iphone-dev-757</link>
		<comments>http://robertcarlsen.net/2009/05/31/using-openframeworks-for-iphone-dev-757#comments</comments>
		<pubDate>Sun, 31 May 2009 16:13:15 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[itpedia]]></category>
		<category><![CDATA[memo.tv]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=757</guid>
		<description><![CDATA[[Also available at ITPedia.  Watch video of the BarCampNYC4 presentation.]
This is an overview of getting set up using openFrameworks for iPhone development.
What is openFrameworks?
openFrameworks is a &#8220;a C++ library for creative coding&#8221;. It shares a similar philosophy with Processing (as a library for Java). The intended audience &#8220;are folks using computers for creative, artistic expression, and [...]]]></description>
			<content:encoded><![CDATA[<p>[Also available at <a href="http://itpedia.nyu.edu/wiki/OpenFrameworks_for_iPhone" onclick="pageTracker._trackPageview('/outgoing/itpedia.nyu.edu/wiki/OpenFrameworks_for_iPhone?referer=');">ITPedia</a>.  Watch video of the BarCampNYC4 <a href="http://robertcarlsen.net/blog/2009/06/03/barcampnyc4-presentation-773">presentation</a>.]</p>
<p>This is an overview of getting set up using openFrameworks for iPhone development.</p>
<h3>What is openFrameworks?</h3>
<p>openFrameworks is a &#8220;a C++ library for creative coding&#8221;. It shares a similar philosophy with Processing (as a library for Java). The intended audience &#8220;are folks using computers for creative, artistic expression, and who would like low level access to the data inside of media in order manipulate, analyze or explore.&#8221;</p>
<p>There are good resources for reading more about it below, under the Resources heading. This article assumes basic knowledge of programming and of the Xcode development environment. You can simply follow along and launch the demo app, but you should really read the resources to understand the structure of a typical openFrameworks-based application.</p>
<h3>Why?</h3>
<p>iPhone native application development is typically done in Objective-C. Not pressing the merits and detractions of Obj-C, but it’s *another* language to learn. If you have code / experience working in C++ then you can use oF to migrate those programs to the iPhone somewhat painlessly. Arguably easier to begin working with &#8211; espeically if you&#8217;re coming from experience with Processing.</p>
<h3>Why not?</h3>
<p>However, if you already develop in Objective-C, then maybe you don&#8217;t need to use oF. OpenFrameworks is not as well documented as Objective-C (even though Apple&#8217;s docs are as dense as the proverbial stereo instructions joke). Certain applications are not as suitable (lots of hierarchal views) It&#8217;s very easy to overwhelm the iPhone if porting desktop oF code over.</p>
<p>Ultimately, however, this eliminates 90% of Obj-C. Still need to use Obj-C (or Obj-C++) to use iPhone interface widgets. Don’t worry about it right now.<span id="more-757"></span></p>
<h3>Credit</h3>
<p>The openFrameworks team did great work under the hood of version 006 to enable this. ofxiphone was compiled by Lee Byron, Memo Akten, Damian Stewart, Zach Gage, and the core OF team (Zach, Theo, and Arturo).</p>
<h3>Resources</h3>
<p>Get the necessary software for development.</p>
<ol>
<li>iPhone development tools
<ul>
<li><span><a href="http://developer.apple.com/iphone/" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/iphone/?referer=');">http://developer.apple.com/iphone/</a></span> &#8211; create (free) iPhone developer account / get iPhone SDK (includes Xcode)</li>
</ul>
</li>
<li>openFrameworks
<ul>
<li><a href="http://www.openframeworks.cc/download" onclick="pageTracker._trackPageview('/outgoing/www.openframeworks.cc/download?referer=');">http://www.openframeworks.cc/download</a><span> &#8211; iPhone version</span></li>
</ul>
</li>
<li>Start reading
<ul>
<li><a href="http://wiki.openframeworks.cc/index.php?title=Main_Page" onclick="pageTracker._trackPageview('/outgoing/wiki.openframeworks.cc/index.php?title=Main_Page&amp;referer=');">http://wiki.openframeworks.cc/index.php?title=Main_Page</a></li>
<li><a href="http://wiki.openframeworks.cc/index.php?title=OF_for_Processing_users" onclick="pageTracker._trackPageview('/outgoing/wiki.openframeworks.cc/index.php?title=OF_for_Processing_users&amp;referer=');">http://wiki.openframeworks.cc/index.php?title=OF_for_Processing_users</a></li>
<li><a href="http://wiki.openframeworks.cc/index.php?title=OfxiPhone_comprehensive_guide" onclick="pageTracker._trackPageview('/outgoing/wiki.openframeworks.cc/index.php?title=OfxiPhone_comprehensive_guide&amp;referer=');">http://wiki.openframeworks.cc/index.php?title=OfxiPhone_comprehensive_guide</a></li>
<li><a style="text-decoration: none;" href="http://www.memo.tv/ofxiphone" onclick="pageTracker._trackPageview('/outgoing/www.memo.tv/ofxiphone?referer=');">http://www.memo.tv/ofxiphone</a></li>
</ul>
</li>
</ol>
<h3>Basic set-up</h3>
<ul>
<li>Install openFrameworks in the Developer folder (out of habit)
<ul>
<li>oF examples live inside the &#8220;of_preRelease_v0.06_iphone/apps/examples&#8221; folder</li>
<li>You can create an alternative folder within &#8220;apps&#8221; for your work (I use &#8220;sketchbook&#8221;)</li>
</ul>
</li>
</ul>
<ul>
<li><strong>Tip!</strong> Install one of the example projects in the Xcode template directory
<ul>
<li>&#8220;/Developer/Library/Xcode/Project Templates/Other&#8221;</li>
<li>You can then start a new project at File&gt;New Project&#8230; then select Other in the left panel.</li>
</ul>
</li>
</ul>
<ul>
<li><strong>Alternative Tip!</strong> Install Memo&#8217;s openFrameworks project templates
<ul>
<li>Download the <a class="external text" title="http://www.memo.tv/xcode_templates_for_openframeworks_on_desktop_and_iphone" rel="nofollow" href="http://www.memo.tv/xcode_templates_for_openframeworks_on_desktop_and_iphone" onclick="pageTracker._trackPageview('/outgoing/www.memo.tv/xcode_templates_for_openframeworks_on_desktop_and_iphone?referer=');">templates</a>.</li>
<li>Unzip the file and copy the openFrameworks folder to:</li>
<li>&#8220;/Developer/Library/Xcode/Project Templates/&#8221;</li>
</ul>
</li>
</ul>
<h3>Example Application</h3>
<p><img class="size-full wp-image-762 alignnone" title="350px-of_iphone_demojpg" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/05/350px-of_iphone_demojpg.jpeg" alt="350px-of_iphone_demojpg" width="350" height="188" /></p>
<ul>
<li>Memo’s simple demo
<ul>
<li><a style="text-decoration: none;" href="http://www.memo.tv/openframeworks_on_iphone_sample_1" onclick="pageTracker._trackPageview('/outgoing/www.memo.tv/openframeworks_on_iphone_sample_1?referer=');">http://www.memo.tv/openframeworks_on_iphone_sample_1</a></li>
</ul>
</li>
</ul>
<ul>
<li>Improved demo &#8211; based on the Touch+Accel demo in the examples folder.
<ul>
<li>Enables multitouch &#8211; select up to five objects at once</li>
<li>Can toss objects around screen.</li>
<li>Download the <a href="http://www.robertcarlsen.net/media/of_iphone_demo.zip" onclick="pageTracker._trackPageview('/outgoing/www.robertcarlsen.net/media/of_iphone_demo.zip?referer=');"><span>demo code</span></a>. (remember to install in apps/sketchbook)</li>
</ul>
</li>
</ul>
<ul>
<li>Select the Simulator in the Active SDK target menu:<br />
<img class="alignnone size-full wp-image-766" title="simulator_targetjpg" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/05/simulator_targetjpg.jpeg" alt="simulator_targetjpg" width="331" height="74" /></li>
</ul>
<ul>
<li>Select Build and Go to compile, install in the Simulator and launch the app:<br />
<img class="alignnone size-full wp-image-763" title="buildgojpg" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/05/buildgojpg.jpeg" alt="buildgojpg" width="236" height="75" /></li>
</ul>
<p><strong>Important bits.</strong> The include lines in testApp.h enable the iPhone-specific methods:</p>
<pre class="brush: cpp;">
#include &quot;ofMain.h&quot;
#include &quot;ofxMultiTouch.h&quot;
#include &quot;ofxAccelerometer.h&quot;
</pre>
<p>Initialize multitouch and accelerometer in testApp::setup() in testApp.cpp:</p>
<pre class="brush: cpp;">
ofxAccelerometer.setup();
ofxMultiTouch.addListener(this);
</pre>
<p>ofxMultiTouch provides the following methods:</p>
<pre class="brush: cpp;">
void touchDown(float x, float y, int touchId, ofxMultiTouchCustomData *data = NULL);
void touchMoved(float x, float y, int touchId, ofxMultiTouchCustomData *data = NULL);
void touchUp(float x, float y, int touchId, ofxMultiTouchCustomData *data = NULL);
void touchDoubleTap(float x, float y, int touchId, ofxMultiTouchCustomData *data = NULL);
</pre>
<p>touchId is an identifier of which touch in the current set of multiple touches is currently being evaluated. The Thing class in the demo has an instance variable which stores this, so the object knows which touch it should be responding to.</p>
<p>Currently ofxMultiTouchCustomData is just a struct with the total number of touches in the current set. For example:</p>
<pre class="brush: cpp;">
if( data-&amp;gt;numTouches &amp;gt;= 2 ) {
   // do stuff only when two (or more) touches are down
}
</pre>
<p>ofxAccelerometer.getForce() returns an ofPoint (x,y,z) of the current force.</p>
<h3>Starting a new Project</h3>
<ul>
<li>Create a new Project (using above template picker)
<ul>
<li>Save the project in the apps/sketchbook folder with a unique name</li>
<li>Change the Application name (&#8221;oF iPhone&#8221; by default)
<ul>
<li>Select the Target &#8220;iPhone oF&#8221; from the &#8220;Groups &amp; Files&#8221; panel on the left</li>
<li>File&gt;Get Info</li>
<li>Select the Build tab</li>
<li>Scroll down to &#8220;Product Name&#8221; and customize it as desired. Be aware that long names will be truncated in the iPhone Springboard</li>
</ul>
</li>
</ul>
</li>
<li>Customization
<ul>
<li>Change Default.png and Icon.png in the data folder.</li>
</ul>
</li>
</ul>
<p>Modify testApp.h and testApp.cpp as necessary. Feel free to build out extra classes as your project needs them.</p>
<h3>Installing on Device</h3>
<p>You need to get a paid ($99 annually) iPhone Developer Account to install any software on the device, even your own for development. Follow instructions on the iPhone Developer Program Portal. (Somewhat confusing at first-pass)</p>
<ul>
<li><a href="http://developer.apple.com/iphone/manage/certificates/team/howto.action" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/iphone/manage/certificates/team/howto.action?referer=');">Generate a development certificate</a></li>
<li><a href="http://developer.apple.com/iphone/manage/devices/howto.action" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/iphone/manage/devices/howto.action?referer=');">Register your device</a></li>
<li><span><a href="http://developer.apple.com/iphone/manage/bundles/howto.action" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/iphone/manage/bundles/howto.action?referer=');">Create an App ID</a></span> (you can use a wildcard for development of several apps: com.yourname.* )</li>
<li><a href="http://developer.apple.com/iphone/manage/provisioningprofiles/howto.action" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/iphone/manage/provisioningprofiles/howto.action?referer=');">Provision your device</a></li>
</ul>
<p>Again, follow the instructions on the Portal.</p>
<ul>
<li>Project changes for Device installation:
<ul>
<li>Change Info.plist &#8211; add App ID (com. yourname.*)</li>
<li>Select the Target &gt; Get Info &gt; Code Signing. Change to your certificate (iPhone Developer: yourname)</li>
<li>Device Provisioning. Drag the downloaded device provisioning file onto the Xcode Organizer.</li>
</ul>
</li>
</ul>
<h3>Adding UIKit elements</h3>
<p><span><a href="http://www.robertcarlsen.net/media/of_iphone_uikit.zip" onclick="pageTracker._trackPageview('/outgoing/www.robertcarlsen.net/media/of_iphone_uikit.zip?referer=');">Download</a></span> the above multitouch demo with a UIView added for preferences.</p>
<p>You can combine both C++ and Objective-C into one file.</p>
<ul>
<li>Add the UIKit headers to testApp.h:</li>
</ul>
<pre>#import &lt;UIKit/UIKit.h&gt;</pre>
<ul>
<li>Change the file extension of main.cpp and testApp.cpp to .mm (as well as any other custom classes that include both).</li>
<li>Easiest to change the file names in the Finder, drag the renamed files back into Xcode then remove the .cpp files (should be red)</li>
</ul>
<p><img class="alignnone size-full wp-image-760" title="of_uiview_list" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/05/of_uiview_list.png" alt="of_uiview_list" width="208" height="157" /></p>
<p>Best practice seems to be to add a UIView (or UIViewController&#8217;s view) as a subview of the application&#8217;s window. The window is accessible by:</p>
<pre class="brush: cpp;">
[[UIApplication sharedApplication] keyWindow]
</pre>
<p>The demo uses a subclass of UIViewController called MyViewController to load an Interface Builder created view. In testApp::setup():</p>
<pre class="brush: cpp;">
// for the UIView GUI stuff:
myViewController = [[MyViewController alloc] initWithNibName:@&quot;MyView&quot; bundle:nil];
</pre>
<p><strong>Important!</strong> MyView.xib needs to be aware of it&#8217;s UIViewController, called MyViewController in the demo. This sounds a bit confusing, but is straightforward &#8211; follow along with the screenshots below.</p>
<ul>
<li>Set the Class property of File&#8217;s Owner to MyViewController:<br />
<img class="size-full wp-image-764 alignnone" title="myviewcontroller" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/05/myviewcontroller.png" alt="myviewcontroller" width="294" height="190" /></li>
</ul>
<ul>
<li>Then connect the File&#8217;s Owner view outlet to the UIView&#8217;s view property:<br />
<img class="alignnone size-full wp-image-765" title="myviewview" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/05/myviewview.png" alt="myviewview" width="294" height="193" /></li>
</ul>
<ul>
<li>Display the view by inserting the view into the window (this is in testApp.mm):</li>
</ul>
<pre class="brush: cpp;">
[[[UIApplication sharedApplication] keyWindow] addSubview:myViewController.view];
</pre>
<ul>
<li>Dismiss it by removing the view from the window (also in testApp.mm):</li>
</ul>
<pre class="brush: cpp;">
[myViewController.view removeFromSuperview];
</pre>
<ul>
<li>The demo actually uses a method in the view controller to remove itself, which looks like (MyViewController.m):</li>
</ul>
<pre class="brush: cpp;">
[[self view] removeFromSuperview];
</pre>
<ul>
<li>You can also add animated transitions and all the other UIKit goodies&#8230;but that&#8217;s for another day.</li>
</ul>
<ul>
<li>You can use standard IBOutlet and IBAction objects to send signals between your view controls and program logic. That is outside of the scope of this overview. So is the Model-View-Controller (MVC) paradigm&#8230;but I&#8217;d create a singleton data object&#8230;and have your view controller and testApp classes access it&#8230;if I were you, and all.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/05/31/using-openframeworks-for-iphone-dev-757/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>counting change</title>
		<link>http://robertcarlsen.net/2009/03/26/counting-change-614</link>
		<comments>http://robertcarlsen.net/2009/03/26/counting-change-614#comments</comments>
		<pubDate>Thu, 26 Mar 2009 22:44:56 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Spatial Media]]></category>
		<category><![CDATA[itp]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=614</guid>
		<description><![CDATA[
As an in-class exercise for Spatial Media we were asked to develop a program which would identify coins in a series of supplied images and tally up their total value. In one hour.
Since time was limited, I decided to use pixel count as a rough estimate of each coin&#8217;s size. This works very reliably with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofcountingchange.png" rel="lightbox[614]"><img class="alignright size-thumbnail wp-image-615" title="ofcountingchange" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofcountingchange-150x150.png" alt="ofcountingchange" width="150" height="150" /></a></p>
<p>As an in-class exercise for Spatial Media we were asked to develop a program which would identify coins in a series of supplied images and tally up their total value. In one hour.</p>
<p>Since time was limited, I decided to use pixel count as a rough estimate of each coin&#8217;s size. This works very reliably with the sample set of images, but that&#8217;s likely because the images consist of duplicated coins and are on a solid white background. Several additional methods wold likely need to be implemented to deal with actual situations. (Code below)<span id="more-614"></span></p>
<p>Nevertheless, simple thresholding isolates the coins from the background and a seed fill algorithm identifies separate objects. The size of each found object is compared against calibrated values and the coin&#8217;s identity/value is inferred from that.</p>
<p>It was a fun (for me) challenge to develop the program in a limited time. I did spend some time after class cleaning up the display and implementing an interactive method to change the image for analysis.</p>
<p>Code (oF xcode project): <a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofcountingchange.zip">ofCountingChange.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/03/26/counting-change-614/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>openFrameworks + iPhone libs</title>
		<link>http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593</link>
		<comments>http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593#comments</comments>
		<pubDate>Thu, 26 Mar 2009 04:09:19 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[lib]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[makefile]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=593</guid>
		<description><![CDATA[I&#8217;ve had a few days to test the libraries I cobbled together for using openFrameworks with iPhone and also received positive reports from some folks who tried out the Makefiles I provided to them, so here they are for anyone who&#8217;s willing to try them out. -please make these instructions better if you see fit- [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/of_iphone.png" rel="lightbox[593]"><img class="alignright size-full wp-image-604" title="of_iphone" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/of_iphone.png" alt="of_iphone" width="123" height="119" /></a>I&#8217;ve had a few days to test the libraries I cobbled together for using openFrameworks with iPhone and also received positive reports from some folks who tried out the Makefiles I provided to them, so here they are for anyone who&#8217;s willing to try them out. -please make these instructions better if you see fit- <span id="more-593"></span></p>
<p>Update (7.8.2009): Fixed some errant quote mark substitutions in the freetype configure line. Also corrected a tab formatting error in the freeimage makefile.</p>
<p>Ok, here goes. This is going to be a work-in-progress document. Of course, there are no promises with this and your mileage may vary&#8230;but it&#8217;s been working for me. Please report success (and trouble, hopefully with workarounds).</p>
<p>The basic &#8220;tutorial&#8221; I followed is on Memo Akten&#8217;s blog, <a href="http://memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone" onclick="pageTracker._trackPageview('/outgoing/memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone?referer=');">memo.tv</a></p>
<p>I&#8217;d highly suggest following Memo&#8217;s tutorial for setting up the development environment. However, there are three libraries that he mentions in his article that need to be built for the iPhone specifically: <a href="http://code.google.com/p/iphone-glu/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/iphone-glu/?referer=');">glu</a>, <a href="http://www.freetype.org/" onclick="pageTracker._trackPageview('/outgoing/www.freetype.org/?referer=');">freetype</a> and <a href="http://freeimage.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/freeimage.sourceforge.net/?referer=');">freeimage</a>. Although he mentions that they have been ported to iPhone I wasn&#8217;t able to locate binaries of the libraries, and went through the process of cross-compiling them myself. This post documents what I needed to do to accomplish that.</p>
<p>You&#8217;ll need to download the source for each of the libraries listed above, as well as a svn copy of open frameworks plus the <a href="http://code.google.com/p/ofxiphone/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/ofxiphone/?referer=');">ofxiPhone</a>, <a href="http://code.google.com/p/ofxmsaof/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/ofxmsaof/?referer=');">ofxMultiTouch and ofxAccelerometer</a> addons. I preferred to use <a href="http://github.com/lian/ofx-dev/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/lian/ofx-dev/tree/master?referer=');">ofx-dev</a> which bundled this and many more addons. You also need the <a href="http://developer.apple.com/" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/?referer=');">Apple Developer Tools</a> including Xcode and the iPhone SDK.</p>
<p><strong>GLU for iPhone:</strong><br />
The glu for iphone package builds painlessly. Build twice: once for the iPhone, once for the iPhone Simulator. Make sure to do a &#8220;make clean&#8221; before building the second version. The readme explains the make command. I copied the entire folder to ofx-dev/libs/gluiphone</p>
<p>The other two were more difficult for me. I&#8217;ve never cross-compiled, so perhaps that contributed to the trouble I had.</p>
<p><strong>FreeImage:</strong><br />
Here is the makefile that I came up with, based on the existing files and what I saw in the glu makefile. Copy the makefile listed below as &#8220;Makefile.iphone&#8221; alongside the others in the source directory, then run &#8220;make -f Makefile.iphone&#8221;. This should build both the iPhone and iPhone Simulator libraries into the &#8220;Dist&#8221; folder. Copy both files to ofx-dev/libs/freeimage/lib</p>
<div style="max-width:550px">
<pre class="brush: cpp; wrap-lines: false;">
# Configuration for iPhone OS, making static libs
# this will generate both iPhone (arm) and iPhoneSimulator (i686) libs

include Makefile.srcs

CFLAGS =  -g -O2 -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing
CXXFLAGS =  -g -O2 -Wall -fno-strict-aliasing

GCC_VERSION = 4.0
IPHONEOS_DEPLOYMENT_TARGET = 2.1
MACOSX_DEPLOYMENT_TARGET = 10.5

PLATFORM_SIM = iPhoneSimulator
PLATFORM_PHONE = iPhoneOS

ARCH_SIM = i686
ARCH_PHONE = armv6

PLATFORM_SIM_DEVELOPER_BIN_DIR = /Developer/Platforms/$(PLATFORM_SIM).platform/Developer/usr/bin
PLATFORM_PHONE_DEVELOPER_BIN_DIR = /Developer/Platforms/$(PLATFORM_PHONE).platform/Developer/usr/bin

SDKROOT_SIM = /Developer/Platforms/$(PLATFORM_SIM).platform/Developer/SDKs/$(PLATFORM_SIM)$(IPHONEOS_DEPLOYMENT_TARGET).sdk
SDKROOT_PHONE = /Developer/Platforms/$(PLATFORM_PHONE).platform/Developer/SDKs/$(PLATFORM_PHONE)$(IPHONEOS_DEPLOYMENT_TARGET).sdk

EXTRA_CFLAGS_SIM += -arch $(ARCH_SIM) -pipe -mdynamic-no-pic -fvisibility=hidden $(INCLUDE) -isysroot $(SDKROOT_SIM)
EXTRA_LDFLAGS_SIM += -arch $(ARCH_SIM) -isysroot $(SDKROOT_SIM) -Wl,-dead_strip
EXTRA_CFLAGS_SIM += -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
EXTRA_LDFLAGS_SIM += -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)

EXTRA_CFLAGS_PHONE += -arch $(ARCH_PHONE) -pipe -mdynamic-no-pic -fvisibility=hidden $(INCLUDE) -isysroot $(SDKROOT_PHONE)
EXTRA_LDFLAGS_PHONE += -arch $(ARCH_PHONE) -isysroot $(SDKROOT_PHONE) -Wl,-dead_strip
EXTRA_CFLAGS_PHONE += -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
EXTRA_LDFLAGS_PHONE += -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)

AR_SIM = $(PLATFORM_SIM_DEVELOPER_BIN_DIR)/ar
AR_PHONE = $(PLATFORM_PHONE_DEVELOPER_BIN_DIR)/ar

CC_SIM = $(PLATFORM_SIM_DEVELOPER_BIN_DIR)/gcc-$(GCC_VERSION)
CC_PHONE = $(PLATFORM_PHONE_DEVELOPER_BIN_DIR)/gcc-$(GCC_VERSION)

CFLAGS_SIM = $(CFLAGS) $(EXTRA_CFLAGS_SIM)
LDFLAGS_SIM = $(EXTRA_LDFLAGS_SIM)
CXX_SIM = $(PLATFORM_SIM_DEVELOPER_BIN_DIR)/g++-$(GCC_VERSION)
CXXFLAGS_SIM += $(EXTRA_CFLAGS_SIM) -fvisibility-inlines-hidden
LIBTOOL_SIM = /Developer/Platforms/$(PLATFORM_SIM).platform/Developer/usr/bin/libtool

CFLAGS_PHONE = $(CFLAGS) $(EXTRA_CFLAGS_PHONE)
LDFLAGS_PHONE += $(EXTRA_LDFLAGS_PHONE)
CXX_PHONE = $(PLATFORM_PHONE_DEVELOPER_BIN_DIR)/g++-$(GCC_VERSION)
CXXFLAGS_PHONE += $(EXTRA_CFLAGS_PHONE) -fvisibility-inlines-hidden
LIBTOOL_PHONE = /Developer/Platforms/$(PLATFORM_PHONE).platform/Developer/usr/bin/libtool

TARGET = freeimage
STATICLIB_SIM = lib$(TARGET)-iphonesimulator.a
STATICLIB_PHONE = lib$(TARGET)-iphone.a
HEADER = Source/FreeImage.h

.SUFFIXES: .o-i686 .o-arm
MODULES_ARM = $(SRCS:.c=.o-arm)
MODULES_ARM := $(MODULES_ARM:.cpp=.o-arm)
MODULES_i686 = $(SRCS:.c=.o-i686)
MODULES_i686 := $(MODULES_i686:.cpp=.o-i686)

default: all

all: dist

dist: FreeImage
	cp *.a Dist
	cp Source/FreeImage.h Dist

FreeImage: $(STATICLIB_SIM) $(STATICLIB_PHONE)

$(STATICLIB_SIM): $(MODULES_i686)
	$(LIBTOOL_SIM) -arch_only i686 -o $@ $(MODULES_i686)

.c.o-i686:
	$(CC_SIM) $(CFLAGS_SIM) -c $&lt; -o $@

.cpp.o-i686:
	$(CXX_SIM) $(CXXFLAGS_SIM) -c $&lt; -o $@

$(STATICLIB_PHONE): $(MODULES_ARM)
	$(LIBTOOL_PHONE) -arch_only armv6 -o $@ $(MODULES_ARM)

.c.o-arm:
	$(CC_PHONE) $(CFLAGS_PHONE) -c $&lt; -o $@

.cpp.o-arm:
	$(CXX_PHONE) $(CXXFLAGS_PHONE) -c $&lt; -o $@

clean:
	rm -f core Dist/*.* u2dtmp* $(MODULES_i686) $(MODULES_ARM) $(STATICLIB_SIM) $(STATICLIB_PHONE)
</pre>
</div>
<p><strong>FreeType:</strong><br />
Their makefile situation got me all confused so i just passed command like configure arguments as necessary. This is pretty ugly. -Please make this better someone-</p>
<div style="max-width:550px">
<pre class="brush: cpp; wrap-lines: false;">
#building freetytpe for iphone
# for iPhone
./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 CFLAGS=&quot;-arch armv6 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include/libxml2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk&quot; CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar LDFLAGS=&quot;-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -Wl,-dead_strip -miphoneos-version-min=2.0&quot;

# for iPhone simulator
./configure --prefix=/usr/local/iphone --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 CFLAGS=&quot;-arch i686 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -mmacosx-version-min=10.5  -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/ -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk&quot; CPP=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar LDFLAGS=&quot;-arch i686 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk -Wl,-dead_strip -mmacosx-version-min=10.5&quot;
</pre>
</div>
<p>Run one of the configure lines, then make. I got an error about &#8220;asm&#8221; being undefined&#8230;I think it was in include/freetype/config/ftconfig.h. Change &#8220;asm&#8221; to &#8220;__asm__&#8221; (that&#8217;s two underscores for both prefix and suffix). If it works then it drops the lib in a hidden dir: &#8220;./objs/.libs&#8221;.  Copy the static lib out of there and rename it as appropriate.  i&#8217;m using libfreetype-iphone.a and libfreetype-iphonesimulator.a. Run make clean and then run the other configure line and make again. There were some headers missing in from the freetype lib provided with ofx-dev that I noticed in the example ofxiPhone aps&#8230;so I copied the entire freetype folder to ofx-dev/libs/freetype-iphone. I put the libraries into freetype-iphone/lib so i could keep everything straight when setting up xcode.</p>
<p>Ok, I think this gets up to the point where we can set up xcode.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofxiphone_xcode.png" rel="lightbox[593]"><img class="alignright size-thumbnail wp-image-602" title="ofxiphone_xcode" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofxiphone_xcode-150x150.png" alt="ofxiphone_xcode" width="150" height="150" /></a>Copy one of the ofxiPhone examples to ofx-dev/apps/dev and open it up in xcode. I used the Graphics example. There is some more explanation on Memo&#8217;s site about the project structure, but it was very similar to adding any other addons. However, I put gluiphone, freetype-iphone and freeimage into the libs&gt;core&gt;core libraries package in the xcode project. I&#8217;ve attached a screenshot to illustrate better than i can explain. (ofxVectorMath is there for the specific project i have open, is not required).</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/user-search-paths.png" rel="lightbox[593]"><img class="alignleft size-thumbnail wp-image-603" style="margin-right: 2px;" title="user-search-paths" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/user-search-paths-150x150.png" alt="user-search-paths" width="150" height="150" /></a></p>
<p>Go to menu Project&gt;Edit Project Settings&#8230; and switch to the build tab. Set configuration to &#8220;All Configurations&#8221; and add in the library and header search paths as appropriate&#8230;just like setting up addons.</p>
<p>Set the Overview to Simulator &#8211; 2.0 | Debug and try to build. Make sure that all the appropriate libraries have been added to the Target. xcode seems to be able to pick the correct ones for the given architecture.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/library-search-paths.png" rel="lightbox[593]"><img class="size-thumbnail wp-image-601 alignright" title="library-search-paths" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/library-search-paths-150x125.png" alt="library-search-paths" width="150" height="125" /></a></p>
<p>I initially got an error about a bad BOOL typedef in FreeImage.h:130 I changed it to typedef int8_t BOOL. In perhaps a separate issue, I don&#8217;t seem to be able to use the &#8220;Boolean&#8221; datatype, but can replace it with &#8220;bool&#8221; instead.</p>
<p>So, that&#8217;s what I did to get my system all set up to use openFrameworks with the iPhone. Feel free to let me know how it works out if you use this for yourself. Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>openFrameworks + iPhone</title>
		<link>http://robertcarlsen.net/2009/03/16/openframeworks-iphone-586</link>
		<comments>http://robertcarlsen.net/2009/03/16/openframeworks-iphone-586#comments</comments>
		<pubDate>Mon, 16 Mar 2009 23:57:09 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=586</guid>
		<description><![CDATA[I&#8217;ve heard about openFrameworks 0.6 (as of yet unreleased) and specifically efforts to support building apps using oF for the iPhone. There are a few developers who have published videos of their efforts and even several apps in the AppStore.
Memo Atken has a very informative article about setting up the prerelease 0.6 version for use [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/particles-iphone.png" rel="lightbox[586]"><img class="alignright size-thumbnail wp-image-587" title="particles-iphone" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/particles-iphone-150x150.png" alt="particles-iphone" width="150" height="150" /></a>I&#8217;ve heard about openFrameworks 0.6 (as of yet unreleased) and specifically efforts to support building apps using oF for the iPhone. There are a few <a href="http://leebyron.com/how/2008/08/31/iphone-yellowtail/" onclick="pageTracker._trackPageview('/outgoing/leebyron.com/how/2008/08/31/iphone-yellowtail/?referer=');">developers</a> who have published videos of their efforts and even several apps in the AppStore.</p>
<p>Memo Atken has a very <a href="http://memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone" onclick="pageTracker._trackPageview('/outgoing/memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone?referer=');">informative article</a> about setting up the prerelease 0.6 version for use with the ofxiPhone addon. However, there is a HUGE simplification of the steps necessary for getting the supporting libraries installed for use with iPhone.</p>
<p><strong>Update: </strong>freetype/freeimage building instructions have been <a href="http://robertcarlsen.net/blog/2009/03/25/openframeworks-iphone-libs-593">posted.</a><span id="more-586"></span></p>
<p>GLU, FreeType and FreeImage need to be built for use with the iPhone. GLU has a nice <a href="http://code.google.com/p/iphone-glu/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/iphone-glu/?referer=');">iPhone specific project</a> and worked flawlessly. I looked around to see if there were ARM/iPhone built versions of the FreeImage and FreeType libraries already available, but couldn&#8217;t find anything. In the end, I hacked up their respective Makefiles and configure options and eventually got everything compiled. I&#8217;ve never had to manually cross-compile code, and I don&#8217;t *actually* know what I&#8217;m doing&#8230;but I can sure copy-paste like a fiend.</p>
<p>Eventually, I&#8217;ll post the specific changes I made, but I want to test it a bit before I expose my embarrassing level of hackery. In the meantime let me know if you&#8217;re itching to get your own environments set up and I&#8217;ll do what I can.</p>
<p>For my &#8220;hello world&#8221; app I ported the particle system from the TrafficFlow project over to the iPhone. It was originally written using oF 0.5 and c++ in xcode, so it was relatively trivial to update for the iPhone with the ofxiPhone addon. I&#8217;m using <a href="http://github.com/lian/ofx-dev/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/lian/ofx-dev/tree/master?referer=');">ofx-dev</a> as the codebase. Using the built-in multi touch library sure beats building the computer vision tracking we&#8217;re using for the table! Teaser video below.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/to70HMNxhVc&#038;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/to70HMNxhVc&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/03/16/openframeworks-iphone-586/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TrafficFlow: Prototype</title>
		<link>http://robertcarlsen.net/2009/03/13/trafficflow-prototype-575</link>
		<comments>http://robertcarlsen.net/2009/03/13/trafficflow-prototype-575#comments</comments>
		<pubDate>Sat, 14 Mar 2009 02:57:33 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Spatial Media]]></category>
		<category><![CDATA[itp]]></category>
		<category><![CDATA[interactive surface]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[traffic flow]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=575</guid>
		<description><![CDATA[Ameya and I presented the prototype of TrafficFlow yesterday at ITP for our Spatial Media midterm project. It is an installation-based table which visualizes wireless traffic on a local network as gracefully flowing rivers of light.
Each user on a network has an individual connection to the internet and may have a conceptual model of personalized [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/flow-dark.jpg" rel="lightbox[575]"><img class="alignright size-thumbnail wp-image-577" title="flow-dark" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/flow-dark-150x150.jpg" alt="flow-dark" width="150" height="150" /></a>Ameya and I presented the prototype of TrafficFlow yesterday at ITP for our Spatial Media midterm project. It is an installation-based table which visualizes wireless traffic on a local network as gracefully flowing rivers of light.</p>
<p>Each user on a network has an individual connection to the internet and may have a conceptual model of personalized &#8220;tube&#8221;. However, all traffic on a typical network shares the same infrastructure and commingles at some point, and if unencrypted, is available to any other member of the network. TrafficFlow aims to make visible this hidden connection.<span id="more-575"></span></p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/flow-wide.jpg" rel="lightbox[575]"><img class="alignleft size-thumbnail wp-image-580" style="margin-right: 2px;" title="flow-wide" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/flow-wide-150x150.jpg" alt="flow-wide" width="150" height="150" /></a>Connecting to the table&#8217;s public network begins the process. The user is directed to a welcome page and asked to place their device on the table, which creates a glowing circle around it. After the table detects the device, they are prompted to confirm that the highlighted device is theirs. As soon as they affirm their connection the circle disappears and their traffic begins to flow.</p>
<p>Reactions to the table varied, but people liked the aesthetic of the flowing light. Several people thought that the lights were too organic to represent digital data. Ameya and I discussed this point but feel that we wanted to stay away from a hard edged, bit-based visual. Instead we are looking to show the data as energy, something almost alive. Another observation is that people really enjoyed manipulating the light with their hands in demo mode without the back end of the data representation. That is certainly something to consider.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/flow-tracking.jpg" rel="lightbox[575]"><img class="alignright size-thumbnail wp-image-579" title="flow-tracking" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/flow-tracking-150x150.jpg" alt="flow-tracking" width="150" height="150" /></a>The prototype still needs significant work in making the device capturing more robust, but the proof-of-concept is functional – and is demonstrated in the below video. Without getting too technical, the system uses several separate systems to function. A router with a custom Linux firmware based on DD-WRT handles the network connections, captive portal and packet sniffing. A java applet and php script parses the packet output and provides web-based activation which populates a mysql database. The main application is written in C++ using the openFrameworks, openCV and mysql++ libraries. Ameya did the web and database stuff and I focused on the visualization/camera vision software. This is the most extensive software that I&#8217;ve written so far, but it&#8217;s been worth the work.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/devicesflow.png" rel="lightbox[575]"><img class="alignleft size-thumbnail wp-image-576" style="margin-right: 2px;" title="devicesflow" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/devicesflow-150x150.png" alt="devicesflow" width="150" height="150" /></a>The table was custom built by several of us in the Spatial Media class. It has a plexiglass surface with a sheet of mylar for diffusion. It provided for under sensing with an IR camera and under projection, using a mirror to bounce the image off the floor. For most of us it was the first interactive surface that we&#8217;ve worked with and was challenging. The results of the prototype table are somewhat frustrating, but I think it could be made much more robust with more refinement. A good learning experience.</p>
<p>Enjoy the videos.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/ezzJpkSSXpA&#038;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/ezzJpkSSXpA&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/jBQisNoKQ5g&#038;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/jBQisNoKQ5g&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/03/13/trafficflow-prototype-575/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
