<?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>Martin&#039;s Place</title>
	<atom:link href="http://www.mfoot.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mfoot.com</link>
	<description></description>
	<lastBuildDate>Sun, 22 Apr 2012 19:38:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Conway&#8217;s Game of Life in CoffeeScript</title>
		<link>http://www.mfoot.com/2012/04/conways-game-of-life-in-coffeescript/</link>
		<comments>http://www.mfoot.com/2012/04/conways-game-of-life-in-coffeescript/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 19:38:55 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=327</guid>
		<description><![CDATA[I recently wanted to give CoffeeScript a try, so I decided to implement Conway&#8217;s Game of Life in CoffeeScript using an HTML5 canvas element for rendering. It was remarkably simple and CoffeeScript seems to be a big improvement over vanilla &#8230; <a href="http://www.mfoot.com/2012/04/conways-game-of-life-in-coffeescript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently wanted to give <a title="CoffeeScript" href="http://coffeescript.org/">CoffeeScript</a> a try, so I decided to implement Conway&#8217;s Game of Life in CoffeeScript using an HTML5 canvas element for rendering. It was remarkably simple and CoffeeScript seems to be a big improvement over vanilla JavaScript in terms of terseness of syntax. It&#8217;s easy to learn an cuts down on a lot of brackets etc. The demo and source code are <a title="Conway's Game of Life in CoffeeScript" href="http://mfoo.github.com/CoffeeScript-Game-Of-Life/">hosted on GitHub here</a>.</p>
<p><a href="http://www.mfoot.com/wp-content/uploads/2012/04/canvas.png"><img class="aligncenter size-medium wp-image-329" title="Conway's Game of Life" src="http://www.mfoot.com/wp-content/uploads/2012/04/canvas-300x180.png" alt="" width="300" height="180" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2012/04/conways-game-of-life-in-coffeescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vim Cheatsheets</title>
		<link>http://www.mfoot.com/2012/04/vim-cheatsheets/</link>
		<comments>http://www.mfoot.com/2012/04/vim-cheatsheets/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 17:18:37 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=321</guid>
		<description><![CDATA[I&#8217;ve been using Vim for about four years, but I&#8217;ve recently started making the effort to use some of the more advanced features outside of the core set that I usually use. Surprisingly there&#8217;s even some basic navigation commands that &#8230; <a href="http://www.mfoot.com/2012/04/vim-cheatsheets/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Vim for about four years, but I&#8217;ve recently started making the effort to use some of the more advanced features outside of the core set that I usually use. Surprisingly there&#8217;s even some basic navigation commands that I never really learned that greatly improve editing efficiency, so I&#8217;ve been using a couple of cheat sheets that come highly recommended. Here they are:</p>
<p><a title="Vim cheatsheets" href="http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html">http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html</a></p>
<p><a title="Vim cheatsheets" href="https://github.com/LevelbossMike/vim_shortcut_wallpaper/">https://github.com/LevelbossMike/vim_shortcut_wallpaper/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2012/04/vim-cheatsheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly Link Roundup 26th March – 1st April</title>
		<link>http://www.mfoot.com/2012/04/weekly-link-roundup-26th-march-1st-april/</link>
		<comments>http://www.mfoot.com/2012/04/weekly-link-roundup-26th-march-1st-april/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 14:33:18 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Roundup]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[chef]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[MIT]]></category>
		<category><![CDATA[netflix]]></category>
		<category><![CDATA[noops]]></category>
		<category><![CDATA[PAAS]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=314</guid>
		<description><![CDATA[A few weeks have gone since my last roundup, I have moved house and started working at a new job so haven&#8217;t had much time. That said, here&#8217;s a list of articles that I&#8217;ve found interesting over the past week. &#8230; <a href="http://www.mfoot.com/2012/04/weekly-link-roundup-26th-march-1st-april/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few weeks have gone since my last roundup, I have moved house and started working at a new job so haven&#8217;t had much time. That said, here&#8217;s a list of articles that I&#8217;ve found interesting over the past week. I&#8217;ve been getting into the &#8216;devops&#8217; world recently (or at least using some of the domain tools and learning about scalable infrastructures), so many of the links are related.</p>
<p><iframe src="http://www.youtube.com/embed/6b4ZZQkcNEo" frameborder="0" width="560" height="315"></iframe></p>
<p><span id="more-314"></span></p>
<ul>
<li>Above is a video from HackADay about a new robot called the Sand Flea that <a title="Sand Flea" href="http://hackaday.com/2012/03/31/sand-flea-literally-leaps-tall-buildings-in-a-single-bound/">has an impressive ability to jump over obstacles</a>. This could be very useful for robotic exploration in areas of difficult terrain.</li>
<li>A scientist has taken over 90,000 hours of video of his baby son via cameras all around the house in order to try and understand the learning of language and how we pick up and reproduce new words. I&#8217;m sure that I&#8217;ve seen a video of this before a few years ago, but now there is a lot more footage and similarly more interesting results. Read more about it including several videos <a href="http://www.fastcompany.com/1733627/mit-scientist-captures-his-sons-first-90000-hours-on-video">here</a>.</li>
<li>The <a href="http://weblog.rubyonrails.org/2012/3/30/ann-rails-3-2-3-has-been-released/">new version of Rails</a> has been released, which among other things addresses the <em>config.active_record.whitelist_attributes</em> issue that lead to the <a href="https://github.com/blog/1069-responsible-disclosure-policy">GitHub compromise</a> earlier this year.</li>
<li>Ranjib Dey has an <a href="http://ranjib.posterous.com/infrastructure-tooling-patterns">overview of the main common parts in web infrastructures</a>.</li>
<li>Nikolay Sturm describes how we can <a href="http://blog.nistu.de/2012/03/04/reusability-in-configuration-management-systems/">apply object oriented principles such as the single responsibility principle and object extendability to configuration management systems</a> such as <a href="http://www.opscode.com/chef/">Chef</a>.</li>
<li>Nikolay was also featured on the <a href="http://www.foodfightshow.org/2012/03/episode-6-cookbook-reusability-with.html">Food Fight podcast talking about Cookbook reusability with Chef</a>.</li>
<li><a title="Etsy" href="http://www.etsy.com">Etsy</a> have <a href="http://codeascraft.etsy.com/2012/03/13/making-it-virtually-easy-to-deploy-on-day-one/">a blog post </a>describing how their infrastructure can scale and pump out new VMs so that newly hired employees can push something to production on their first day. It&#8217;s interesting seeing which tools they use and how they use them to facilitate this.</li>
<li>Netflix maintain a technical blog that describes some of the challenges they face and how they go about overcoming them. One in particular talks about <a href="http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html">fault tolerance in high volume distributed systems</a> and is a useful read for anybody designing a service based architecture.</li>
<li>John Vincent discusses requirements to be able to <a href="http://blog.lusis.org/blog/2012/03/06/graphs-in-operations/">accurately graph dependencies at macro and micro levels</a> in order to efficiently act upon changes in the dependency hierarchy.</li>
<li>Finally, in a less educational but more entertaining capacity, I have been reading several articles each trying to clarify what DevOps really is and if/why it&#8217;s actually useful. Make what you will of the content. <a href="http://www.brunton-spall.co.uk/post/2012/03/13/what-is-devops-not/">What DevOps is not</a>, <a href="http://perfcap.blogspot.co.uk/2012/03/ops-devops-and-noops-at-netflix.html">Ops, DevOps and PaaS (NoOps) at Netflix</a>, and <a href="https://gist.github.com/2140086">a response to that post</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2012/04/weekly-link-roundup-26th-march-1st-april/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Joy of Programming</title>
		<link>http://www.mfoot.com/2012/03/the-joy-of-programming/</link>
		<comments>http://www.mfoot.com/2012/03/the-joy-of-programming/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 00:13:33 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[mythical man month]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=300</guid>
		<description><![CDATA[I&#8217;ve recently started reading The Mythical Man Month by Frederick P. Brooks Jr., and I came across several paragraphs that brilliantly and elegantly capture the joy of programming and the reward of solving a problem in five different points. The &#8230; <a href="http://www.mfoot.com/2012/03/the-joy-of-programming/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started reading <a title="Amazon - The Mythical Man Month" href="http://www.amazon.com/Mythical-Man-Month-Software-Engineering-Anniversary/dp/0201835959">The Mythical Man Month by Frederick P. Brooks Jr.</a>, and I came across several paragraphs that brilliantly and elegantly capture the joy of programming and the reward of solving a problem in five different points. The following is a copy of page 7 of the anniversary edition. I would definitely recommend this book to any career programmer.</p>
<p><span id="more-300"></span></p>
<blockquote style="width: 85%;"><p>Why is programming fun? What delights may its practitioner expect as a reward?</p>
<p>First is the sheer joy of making things. As the child delights in his mud pie, so the adult enjoys building things, especially things of his own design. I think this delight must be an image of God&#8217;s delight in making things, a delight shown in the distinctness and newness of each leaf and snowflake.</p>
<p>Second is the pleasure of making things that are useful to other people. Deep within, we want others to use our work and find it helpful. In this respect the programming system is not essentially different from the child&#8217;s first clay pencil holder &#8220;for Daddy&#8217;s office.&#8221;</p>
<p>Third is the fascination of fashioning complex puzzle-like objects of interlocking moving parts and watching them work in subtle cycles, playing out the consequences of principles built in from the beginning. The programmed computer has all the fascination of a pinball machine or the jukebox mechanism, carried to the ultimate.</p>
<p>Fourth is the joy of always learning, which springs from the nonrepeating nature of the task. In one way or other the problem is never new, and its solver learns something: sometimes practical, sometimes theoretical, and sometimes both.</p>
<p>Finally, there is the delight in working with such a tractable medium. The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from the air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures.</p>
<p>Yet the program construct, unlike the poet&#8217;s words, is real in the sense that it moves and works, producing visible outputs separate from the construct itself. It prints results, draws pictures, produces sound, moves arms. The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be.</p>
<p>Programming then is fun because it gratifies creative longings built deep within us and delights sensibilities we have in common with all men.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2012/03/the-joy-of-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly Link Roundup 27th Feb &#8211; 4th March</title>
		<link>http://www.mfoot.com/2012/03/weekly-link-roundup-27th-feb-4th-march/</link>
		<comments>http://www.mfoot.com/2012/03/weekly-link-roundup-27th-feb-4th-march/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 12:49:19 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Roundup]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[collusion]]></category>
		<category><![CDATA[exercise]]></category>
		<category><![CDATA[health]]></category>
		<category><![CDATA[parasite]]></category>
		<category><![CDATA[raspberry pi]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[seeds]]></category>
		<category><![CDATA[time lapse]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=288</guid>
		<description><![CDATA[I&#8217;m going to start taking notes of a few interesting articles/websites that I find each week in order to share them with others and preserve them for myself. And so begins Week One. Links will cover any article that I &#8230; <a href="http://www.mfoot.com/2012/03/weekly-link-roundup-27th-feb-4th-march/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to start taking notes of a few interesting articles/websites that I find each week in order to share them with others and preserve them for myself. And so begins Week One. Links will cover any article that I find interesting, but will largely be grounded in science and technology.</p>
<p><iframe src="http://player.vimeo.com/video/37752523" frameborder="0" width="610" height="343"></iframe></p>
<p><span id="more-288"></span></p>
<ol>
<li>An <a title="Time Lapse" href="http://blogs.discovermagazine.com/badastronomy/2012/03/02/stunning-time-lapse-video-the-light-of-stars/">awesome <strong>time-lapse video of night skies</strong></a> was posted the other day (embedded above). I love stunning videos of nature and this is no exception.</li>
<li>Some scientists as part of a Russian research team have <a title="National Geographic News - Germinating Seeds" href="http://news.nationalgeographic.com/news/2012/02/120221-oldest-seeds-regenerated-plants-science/?source=link-tw20120229news-plant ">reportedly managed to <strong>germinate seeds that were found under 124 feet (38 meters) of permafrost</strong></a> (annoyingly, it doesn&#8217;t link to the source journal article), which were determined to be around 32,000 years old by radiocarbon dating. The article describes how knowledge of unfreezing and re-cultivating these seeds could benefit places such as the Svalbard Global Seed Vault.</li>
<li>A new <a title="Mozilla Collusion Plugin" href="http://www.mozilla.org/en-US/collusion/">experimental plugin for Firefox</a> called Collision that allows you to <strong>visualise the connections between services that websites use to track you while you are online</strong>. It&#8217;s certainly quite eye-opening about the number of websites that record your usage data and statistics. Mozilla writes: <em>Not all tracking is bad. Many services rely on user data to provide relevant content and enhance your online experience. But most tracking happens without users&#8217; consent and without their knowledge. That’s not okay. It should be you who decides when, how and if you want to be tracked. Collusion will be a powerful tool to help you do that</em></li>
<li>The <a title="Raspberry Pi" href="www.raspberrypi.org/">Raspberry Pi foundation</a> also recently announced that they have <strong>started shipping A and B model Raspberry Pis</strong>, although they are currently out of stock in both RS and Farnell. Using these distributors allows for a much higher production rate that scales to demand, and will help reduce shipping costs for people due to worldwide distribution networks. Can&#8217;t wait until they are back in stock.</li>
<li>A <a title="Fish tongue parasites" href="http://blogs.discovermagazine.com/loom/2012/03/02/tongue-parasites-to-people-of-earth-thank-you-for-your-overfishing/">scary post that describes </a><strong><a title="Fish tongue parasites" href="http://blogs.discovermagazine.com/loom/2012/03/02/tongue-parasites-to-people-of-earth-thank-you-for-your-overfishing/">a fish parasite</a> that enters the gills of a fish, devours its tongue, then positions itself in place of the tongue</strong>. Just the picture alone is creepy! Nature is awesome.</li>
<li>A <a title="BBC Horizon - The Truth About Exercise" href="http://www.bbc.co.uk/iplayer/episode/b01cywtq/Horizon_20112012_The_Truth_About_Exercise/">BBC Horizon show</a> about <strong>what exercise really does and the best ways of getting the maximum benefit</strong> (probably UK only). This is coupled with <a title="DiscoverMagazine - Just three days of a sedentary lifestyle can increase blood sugar levels" href="http://blogs.discovermagazine.com/80beats/2012/03/02/just-3-days-of-lazing-around-will-weaken-your-ability-to-regulate-blood-sugar/">a post from DiscoverMagazine</a> on a new study that suggests <strong>healthy people will develop higher blood sugar after only three days of a sedentary lifestyle</strong>.</li>
<li>A <a title="Mark Shuttleworth Ubuntu HUD intro" href="http://www.markshuttleworth.com/archives/939">post from Mark Shuttleworth</a> that shows the <strong>new HUD functionality coming in Ubuntu 12.04</strong>.</li>
<li>A good collection of <a title="30 books everyone in the software business should read and why" href="http://www.dextronet.com/micro-isv-insights/2012/01/30-books-everyone-in-software-business-should-read-and-why/"><strong>30 books that everyone in the software business should read and why</strong></a>. I know that five or six of these are already on my Amazon wishlist for when I have the time, and it&#8217;s definitely a list worth looking at.</li>
<li>An <a title="bin sbin usr/bin usr/sbin" href="lists.busybox.net/pipermail/busybox/2010-December/074114.html">interesting explanation of <strong>why the bin, sbin, usr/bin, and usr/sbin folders exist</strong> in Unix</a> as well as why the programs located in each exist where they do.</li>
<li>A <a title="Tumblr Scalability" href="http://highscalability.com/blog/2012/2/13/tumblr-architecture-15-billion-page-views-a-month-and-harder.html">detailed and very interesting article describing Tumblr&#8217;s scalable architecture</a> and how it allows them to serve &#8217;500 million page views a day, a peak rate of ~40k requests per second, ~3TB of new data to store a day, all running on 1000+ servers&#8217;.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2012/03/weekly-link-roundup-27th-feb-4th-march/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Choosing a maths library for cross-platform C++ game development</title>
		<link>http://www.mfoot.com/2012/01/choosing-a-maths-library-for-cross-platform-c-game-development/</link>
		<comments>http://www.mfoot.com/2012/01/choosing-a-maths-library-for-cross-platform-c-game-development/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 15:35:28 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cmake]]></category>
		<category><![CDATA[CML]]></category>
		<category><![CDATA[eigen]]></category>
		<category><![CDATA[GLM]]></category>
		<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=280</guid>
		<description><![CDATA[I have recently been looking for a C++ maths library for use in game development projects. There are plenty of posts on websites like gamedev.stackexchange.com with suggestions for libraries but few quantitative comparisons between them. I decided to take three &#8230; <a href="http://www.mfoot.com/2012/01/choosing-a-maths-library-for-cross-platform-c-game-development/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have recently been looking for a C++ maths library for use in game development projects. There are plenty of posts on websites like <a title="Game Development Stackexchange" href="http://gamedev.stackexchange.com/">gamedev.stackexchange.com</a> with suggestions for libraries but few quantitative comparisons between them. I decided to take three of the most popular libraries and run some tests of my own. Below I describe the three libraries I&#8217;ve compared with their advantages and disadvantages and then show the results of some performance tests. It&#8217;s important for me to have cross-platform compatibility, so each library selected is header only and has been tested on Mac, Linux, and Android using the NDK. The code and results are also available <a title="C++ Math library test project" href="https://github.com/mfoo/Math-Library-Test">on GitHub</a> for testing.</p>
<p>The libraries tested are:</p>
<ul>
<li><a href="http://eigen.tuxfamily.org/">Eigen</a></li>
<li><a href="http://glm.g-truc.net/">GLM</a></li>
<li><a href="http://cmldev.net/">CML</a></li>
</ul>
<p>These choices are largely influenced by reading their websites and posts at the <a href="http://gamedev.stackexchange.com/">Game Development StackExchange</a> site:</p>
<ul>
<li><a href="http://gamedev.stackexchange.com/questions/9924/best-c-math-library-for-game-engine">Best C Math Library for Game Engine?</a></li>
<li><a href="http://stackoverflow.com/questions/5935075/high-performance-math-library-for-vector-and-matrix-calculations">High Performance Math Library for Vector And Matrix Calculations</a></li>
<li><a href="http://gamedev.stackexchange.com/questions/8234/complete-math-library-for-use-in-opengl-es-2-0-game">Complete Math Library for use in OpenGL ES 2.0 Game?</a></li>
</ul>
<p><span id="more-280"></span></p>
<h1>Requirements</h1>
<p>I have several requirements for a math library, and when rating them (in no particular order) the <a title="What should be taken into consideration when choosing a math library for C++ game development?" href="http://gamedev.stackexchange.com/questions/21711/what-should-be-taken-into-consideration-when-choosing-a-math-library-for-games">following things are important</a>:</p>
<ul>
<li>License</li>
<li>Portability</li>
<li>Quality and quantity of the documentation</li>
<li>Completeness (or how much can the library do without me having to write my own functions). For game development this includes:</li>
<ul>
<li>Matrix operations</li>
<li>Vector operations</li>
<li>Complex number support</li>
<li>Quaternion operations</li>
</ul>
<li>Extensibility and community contributions (linked directly to the above).</li>
<li>Ease of use (are the concepts simple to understand?)</li>
<li>Performance (are there SIMD optimisations?)</li>
</ul>
<h1>Libraries Overview</h1>
<div id="readme">
<div>
<h2>Configurable Math Library (CML)</h2>
<p>This is a free library designed for games, graphics, and computational geometry applications. Listed <a href="http://cmldev.net/?page_id=8">features</a> include:</p>
<ul>
<li>Vector, matrix, and quarternion classes</li>
<li>Templated headers so can be used for arbitrary types</li>
<li>Arbitrary sized vectors and matrices (fixed or dynamically resizable)</li>
<li>Conversions between polar, cylindrical, spherical, and Cartesian coordinates</li>
<li>A large library of functions for the construction and manipulation of transforms in 2D and 3D</li>
</ul>
<p>CML&#8217;s <a href="http://cmldev.net/?page_id=594">design notes</a> state that it is meant to be cross-platform and portable and therefore doesn&#8217;t contain any platform specific optimisations, but it is possible to include them in the future if there is specific interest.</p>
<p>There&#8217;s only one header file to include, <code>cml/cml.h</code>.</p>
<p>CML contains quite a nice way of creating an abstraction layer between existing math library objects and CML objects, allowing the use of other math library data types in CML library functions. See <a href="http://cmldev.net/?p=424">here</a>.</p>
<p>CML only has a few <a href="http://cmldev.net/?p=402">examples</a>. Hasn&#8217;t been updated in a while. Contains useful functions for working with OpenGL or DirectX though, including replacements for things like gluLookAt().</p>
<p>CML is released under the <a href="http://cmldev.net/?p=430">Boost Software License</a>. This means that you&#8217;re allowed to use and profit from the library as long as when distributing CML or any modifications you have made to CML, you keep the Boost Software License text in each file.</p>
<h2>Eigen</h2>
<p>This library has by far the most detailed and descriptive tutorial section with many code samples. It is also worth noting that it seems to be the most frequently updated and the most up-to-date (at the time of writing the most recent release, 3.0.4, was 3.5 weeks ago).</p>
<p>Like GLM, it is very easy to pass the class objects directly to OpenGL, although in Eigen this is performed by an <a href="http://eigen.tuxfamily.org/dox-devel/unsupported/group__OpenGLSUpport__Module.html">unsupported OpenGL module</a> which provides a few functions such as glTranslate and glRotate.</p>
<pre>// You need to add path_to_eigen/unsupported to your include path.
#include &lt;Eigen/OpenGLSupport&gt;
// ...
Vector3f x, y;
Matrix3f rot;
glVertex(y + x * rot);

Quaternion q;
glRotate(q);</pre>
<p>Provides a large number of array, matrix, and vector types with <a href="http://eigen.tuxfamily.org/dox/QuickRefPage.html#QuickRef_Types">many operators</a>.</p>
<p>Eigen is licensed under the LGPL which is quite restrictive and usually would exclude a library based on my requirements. However, Eigen has a large <a href="http://eigen.tuxfamily.org/index.php?title=Licensing_FAQ">Licensing FAQ</a> which tries to answer any licensing questions people might have. Their main point is that as Eigen is a header only library, it does not count as a &#8220;Combined Work&#8221; under the LGPL it can be therefore used entirely under Section 3. This states that to use Eigen you must:</p>
<ul>
<li>Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. The Eigen FAQ states that &#8216;the bottom of a README file or of a website would be prominent enough for us&#8217;.</li>
<li>Accompany the object code with a copy of the GNU GPL and this license document.</li>
</ul>
<p>This assumes that you&#8217;re using Eigen unmodified. If you are planning to make changes to Eigen and release it, then you must also make the modifications available under the LGPL.</p>
<h2>OpenGL Math Library (GLM)</h2>
<p>GLM&#8217;s main design to be very familiar to those who know GLSL as it uses classes and functions that use the GLSL naming conventions. It also seems to provide all of the functionality that I might need in the future.</p>
<p>Includes several code samples, more than CML. Many more located in the manual.</p>
<p>Includes features such as:</p>
<ul>
<li>Math for splines</li>
<li>Math for colour spaces</li>
<li>Random numbers</li>
<li>Simplex noise generation</li>
<li>Conversion of Euler angles</li>
</ul>
<p>There&#8217;s only one header file to include, <code>glm/glm.hpp</code>. <code>glm/ext.hpp</code> can be included to add extended features (non GLSL features).</p>
<p>The design choice to follow GLSL conventions allows the library to be intuitive and easy to use, especially given that data alignment is compatible with gl functions. E.g:</p>
<pre>glm::vec4 v(0);
glm::mat4 m(0);
glVertex3fv(glm::value_ptr(v));
glLoadMatrixfv(glm::value_ptr(m));</pre>
<p>The manual pdf file link is broken but a slightly out of date version can be found <a href="https://bitbucket.org/alfonse/gltut/src/6332c7f79903/glm-0.9.0.0/doc/glm-manual.pdf">here</a>. I&#8217;ve sent the maintainer an email and hopefully this will be fixed shortly.</p>
<p>GLM is licensed under the <a href="http://en.wikipedia.org/wiki/MIT_License">MIT License</a> (Expat License) which is very permissive and means GLM is a good candidate for any project requiring a math library.</p>
</div>
</div>
<p>To run the tests on Android you will need the <a href="http://developer.android.com/sdk/ndk/index.html">Android NDK</a> and <a href="http://code.google.com/p/android-cmake/">android-cmake</a>. For Ant you will need to specify your Android SDK location in <code>android/local.properties</code>. I have included prebuilt libraries for armeabi and armeabi-v7a so if you don&#8217;t want to compile them yourself you can skip straight to the ant commants.</p>
<h1>Results</h1>
<p>So far I&#8217;ve tested matrix addition and multiplication. <code>src/Main.cpp</code> contains code that will generate two lists of 1 million 4&#215;4 float matrices for each library, populate them with random float values, and then add each one from the first column to the second. It will then do the same for multiplication. It will repeat this step 10 times and print out how long it took for each library.</p>
<p>Results for each library vary greatly with architecture and optimisation level. I have tested standard GCC build on Mac OS X Lion as well as an SSE enabled build, and armeabi, armeabi-v7a and armeabi-v7a with NEON instructions for Android.</p>
<p>Note that all tests use the <code>-O2</code> GCC optimisation flag except the non-SSE laptop build which uses <code>-O0</code>.</p>
<p>Results for addition and multiplication are shown below. Note that the laptop I&#8217;m using is an i7 2.2ghz early 2011 MacBook Pro and the Android device is a Stock HTC Desire (2.2) with a 1 GHz Qualcomm QSD8250. All times are in milliseconds.</p>
<pre>                        laptop  laptop (SSE)  armeabi  armeabi-v7a  armeabi-v7a with neon
Eigen additions         8065    30            9944     2181         2145
Eigen multiplications   22404   86            59460    5143         5113
GLM additions           2375    76            10256    1506         1407
GLM multiplications     7337    400           59008    2189         3108
CML additions           12336   96            9587     2885         2996
CML multiplications     21603   551           58399    5306         5280</pre>
<p>The first column for the laptop doesn&#8217;t have any compile-time optimisations and is included purely for interest. From the other results, Eigen seems to be the fastest for these operations, but GLM is the fastest on the HTC Desire with both ABIs. I am not sure why the NEON times are not much faster (and in some cases, slower) but will update this post when I learn more.</p>
<p>Despite GLM being faster on the mobile devices, I am more inclined to use Eigen due to its speed on the tested Intel CPU and its much better documentation and more active community.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2012/01/choosing-a-maths-library-for-cross-platform-c-game-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MDN Holiday Calendar Link Roundup</title>
		<link>http://www.mfoot.com/2011/12/mdn-holiday-calendar-link-roundup/</link>
		<comments>http://www.mfoot.com/2011/12/mdn-holiday-calendar-link-roundup/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 10:00:02 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=266</guid>
		<description><![CDATA[Through the run-up to Christmas 2011, the Mozilla Developer Network has been posting a link a day in their MDN Holiday Calendar. This post serves as a collection of those posts as a time-saver, but the site is worth checking &#8230; <a href="http://www.mfoot.com/2011/12/mdn-holiday-calendar-link-roundup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Through the run-up to Christmas 2011, the Mozilla Developer Network has been posting a link a day in their <a title="MDN Holiday Calendar" href="http://thewebrocks.com/calendar/">MDN Holiday Calendar</a>. This post serves as a collection of those posts as a time-saver, but the site is worth checking out. Note that none of this is my work, the calendar was written by Chris Heilmann with additional links provided by Luke Crouch, Robert Nyman and Rob Hawkes. Source code is <a href="https://github.com/codepo8/calendar-tutorial">available on GitHub</a> and there is a making of tutorial: <a href="http://christianheilmann.com/2011/11/29/building-an-advent-calendar-for-mozilla-in-phpjscss-part-1/">Part 1</a> &#8211; <a href="http://christianheilmann.com/2011/11/29/building-an-advent-calendar-for-mozilla-in-phpjscss-part-2/">Part 2.</a></p>
<p>Also note: this isn&#8217;t an error, at the time of writing numbers 2 and 10 point to the same URL. Number 10 also seems to have a broken quote with half missing! Despite this, some of these articles are really interesting!</p>
<p><span id="more-266"></span></p>
<ol>
<li>
<h1><a href="http://www.andismith.com/blog/2011/11/25-dev-tool-secrets/">25 Secrets of the Browser Developer Tools</a></h1>
<p>Superb explanation and introduction to how you use and get the most out of the Developer Tools in web browsers.</li>
<li>
<h1><a href="http://www.davidflanagan.com/2011/10/html-parsing-wi.html">HTML Parsing with JavaScript</a></h1>
<p>Ever thought of implementing the DOM in JavaScript? David Flanagan shows with dom.js how it can be done.</li>
<li>
<h1><a href="http://sixrevisions.com/css/font-face-web-fonts-issues/">How to Bulletproof @font-face Web Fonts</a></h1>
<p>Working with fonts on the web has always been a challenge. This article aims to clarify as much as possible and take you beyond the common pitfalls.</li>
<li>
<h1><a href="http://experiments.brandoncash.net/elements/">Interactive Periodic Table</a></h1>
<p>Beautiful example of using modern web technologies to create a periodic table &#8211; complete with moving atoms.</li>
<li>
<h1><a href="http://www.thecssninja.com/javascript/fullscreen">Fullscreen HTML5 video</a></h1>
<p>Watching video is nice but it is even nicer if you can do it in fullscreen. This explains how to tap into that possibility in web browsers.</li>
<li>
<h1><a href="http://lights.elliegoulding.com/">Lights </a></h1>
<p>Interactive WebGL music experience.</p>
<p>You can also <a href="http://lights.elliegoulding.com/">see it in action here</a>.</li>
<li>
<h1><a href="http://webglplayground.net/">WebGL playground</a></h1>
<p>This is a great resource to see WebGL code in action and play live with the code</li>
<li>
<h1><a href="https://developer.mozilla.org/en/CSS/CSS_transitions">CSS Transitions</a></h1>
<p>The smoothness of this page is very much the result of using CSS transitions. Check the docs to learn all about them.</p>
<p>You can also <a href="https://developer.mozilla.org/samples/cssref/transitions/sample2/">see it in action here</a>.</li>
<li>
<h1><a href="https://wiki.mozilla.org/GamepadAPI">Gamepad API</a></h1>
<p>Gamepad and joystick support is coming to Firefox and Chrome.</p>
<p>You can also <a href="http://vimeo.com/31906995">see it in action here</a>.</li>
<li>
<h1><a href="http://www.davidflanagan.com/2011/10/html-parsing-wi.html">HTML parsing in JavaScript</a></h1>
<p>&#8220;Next time you shout at some browser for doing it wrong</p>
<p>You can also <a href="http://thewebrocks.com/calendar/check%20out%20how%20hard%20it%20is%20to%20parse%20HTML.">see it in action here</a>.</li>
<li>
<h1><a href="http://popcornjs.org/">Popcorn.js</a></h1>
<p>Popcorn is a Mozilla sponsored project to make it dead easy to sync media with web content.</p>
<p>You can also <a href="http://popcornjs.org/demos">see it in action here</a>.</li>
<li>
<h1><a href="http://www.biomotionlab.ca/Demos/webgl_walker/webgl_walker.php">WebGL Walker</a></h1>
<p>A cool and customizable skeleton done with WebGL. I recommend maxing out the sliders!</p>
<p>You can also <a href="http://www.biomotionlab.ca/Demos/webgl_walker/webgl_walker.php">see it in action here</a>.</li>
<li>
<h1><a href="http://medialize.github.com/jQuery-contextMenu/demo/html5-polyfill-firefox8.html">Context menus in browsers</a></h1>
<p>This is a jQuery polyfill to bring native context menus as supported in Firefox 8+ to all browsers.</p>
<p>You can also <a href="http://hacks.mozilla.org/2011/11/html5-context-menus-in-firefox-screencast-and-code/">see it in action here</a>.</li>
<li>
<h1><a href="http://jlongster.com/2011/11/21/canvas.html">Going Fullscreen with Canvas</a></h1>
<p>Nice and simple example how you can utilize the Fullscreen API to create a complete full-screen canvas experience.</p>
<p>You can also <a href="http://jlongster.com/2011/11/21/canvas.html">see it in action here</a>.</li>
<li>
<h1><a href="http://www.eleqtriq.com/2010/11/natural-object-rotation-with-css3-3d/">Natural Object-Rotation with CSS3 3D</a></h1>
<p>Great article on CSS 3D Transforms with beautiful illustrations. Make sure to use the various web browser prefixes in your CSS code to make it work for as many as possible.</p>
<p>You can also <a href="http://www.eleqtriq.com/wp-content/static/demos/2010/rotation/index.html">see it in action here</a>.</li>
<li>
<h1><a href="http://platform.html5.org/">The Open Web platform: Browser technologies</a></h1>
<p>The Open Web is filled with technologies and specifications that offers web developers a lot of choices. This page is an overview of all those technologies.</li>
<li>
<h1><a href="http://www.martani.net/2010/11/encode-javascript-with-japanese-style.html">Encode JavaScript as Japanese emoticons</a></h1>
<p>This is wild but it also shows that when it comes to filtering out your data for malicious injections looking for alert() doesn&#8217;t cut it.</li>
<li>
<h1><a href="http://nodejs.org/">Node.js</a></h1>
<p>&#8220;Node.js lets you to run JavaScript outside of the browser while utilising the full power of your computer. It allows for a whole variety of use-cases; like game and Web servers or simple applications that scrape and manipulate data.</p>
<p>You can also <a href="http://nodejs.org/">see it in action here</a>.</li>
<li>
<h1><a href="http://www.spielzeugz.de/html5/sticky-thing/">HTML5 Sticky Thing</a></h1>
<p>Nice canvas example which shows a playful example of you you can add nice interaction to a cute feature.</p>
<p>You can also <a href="http://www.spielzeugz.de/html5/sticky-thing/">see it in action here</a>.</li>
<li>
<h1><a href="https://developer.mozilla.org/en/API/Mouse_Lock_API">Mouse Lock API</a></h1>
<p>The Mouse Lock API allows you to lock the position of the mouse and hide the cursor. It is perfect for games and visualisations where you need to look around a 3D world and don&#8217;t want to be restricted by traditional mouse movement on the Web.</li>
<li>
<h1><a href="http://learningthreejs.com/">Learning three.js</a></h1>
<p>Learn how to use the three.js WebGL library to create animations and games.</li>
<li>
<h1><a href="http://dochub.io/">Dochub.io</a></h1>
<p>This is a great find-as-you-type interface to the MDN CSS documentation</li>
<li>
<h1><a href="http://robert.ocallahan.org/2011/11/latency-of-html5-sounds.html">HTML5 audio in games</a></h1>
<p>A small trick to fight the latency of HTML5 audio in Games</li>
<li>
<h1><a href="http://html5doctor.com/video-subtitling-and-webvtt/">Video Subtitling and WebVTT </a></h1>
<p>A great introduction by the HTML5 Doctor on a very important part of online video.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2011/12/mdn-holiday-calendar-link-roundup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-compiling FreeType for Android with CMake</title>
		<link>http://www.mfoot.com/2011/12/cross-compiling-freetype-for-android-with-cmake/</link>
		<comments>http://www.mfoot.com/2011/12/cross-compiling-freetype-for-android-with-cmake/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 15:03:15 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android-cmake]]></category>
		<category><![CDATA[cmake]]></category>
		<category><![CDATA[NDK]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=255</guid>
		<description><![CDATA[Freetype provides a Makefile with a configure utility that makes it fairly easy to cross-compile for other platforms, however there are a lot of examples on the web (as well as some solutions) of people having difficulty in it. My &#8230; <a href="http://www.mfoot.com/2011/12/cross-compiling-freetype-for-android-with-cmake/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Freetype provides a Makefile with a configure utility that makes it fairly easy to cross-compile for other platforms, however there are a lot of examples on the web (as well as some <a title="Cross compile freetype2 for ARM" href="http://zarprime.blogspot.com/2006/08/how-to-cross-compile-freetype.html">solutions</a>) of people having difficulty in it.</p>
<p>My intention is to cross-compile FreeType using the Android NDK into a static library that can ultimately be used by <a title="libRocket HTML and CSS based UI" href="http://librocket.com">libRocket</a> for font rendering in HTML+CSS based UIs in OpenGL applications. I&#8217;m using the <a title="CMake - Home" href="http://cmake.org/">CMake</a> build system for cross-platform builds and the <a title="android-cmake Google Code" href="http://android-cmake.googlecode.com">android-cmake</a> project to create a CMake toolchain for the NDK. This requires creating a CMakeLists.txt for FreeType as it doesn&#8217;t currently provide one.</p>
<p>The CMakeLists.txt file included below is based on the FreeType-2.4.8 release and is a result of converting the Jamfile and Makefile to CMake. Its intention is simply to allow compilation with CMake. For standard build and installs I would recommend following the instructions in the docs/INSTALL file from the FreeType directory. <strong>Note: </strong>This file will try and build *all* of FreeType2&#8242;s modules as defined in include/freetype/config/ftmodule.h. If you don&#8217;t want to build some of these modules please edit that file and remove the macro calls.<span id="more-255"></span>This is a rather brute force method that will compile all the files and modules that are in the default build settings for FreeType. I spent some time trying to add proper CMake style options for each module that also checks their dependencies but didn&#8217;t get too far. You will need to remove files from compilation as needed.</p>
<pre>cmake_minimum_required(VERSION 2.6)

project(FreeType2)

# First, compiler definitions for building the library
add_definitions(-DFT2_BUILD_LIBRARY)
add_definitions("-DFT_CONFIG_MODULES_H=&lt;ftmodule.h&gt;")

# Specify library include directories
include_directories("${PROJECT_SOURCE_DIR}/builds/ansi")
include_directories("${PROJECT_SOURCE_DIR}/include")
include_directories("${PROJECT_SOURCE_DIR}/include/freetype")
#include_directories("${PROJECT_SOURCE_DIR}/include/freetype/config")

# For the auto-generated ftmodule.h file
include_directories("${PROJECT_BINARY_DIR}/include")

include_directories("${PROJECT_SOURCE_DIR}/objs")

#file(GLOB BASE_SRCS "src/base/*.c")

set(BASE_SRCS
    src/base/ftsystem.c
    src/base/ftdebug.c
    src/base/ftinit.c
    src/base/ftbbox.c
    src/base/ftbitmap.c
    src/base/ftcid.c
    src/base/ftadvanc.c
    src/base/ftcalc.c
    src/base/ftdbgmem.c
    src/base/ftgloadr.c
    src/base/ftobjs.c
    src/base/ftoutln.c
    src/base/ftrfork.c
    src/base/ftsnames.c
    src/base/ftstream.c
    src/base/fttrigon.c
    src/base/ftutil.c
    src/base/ftfstype.c
    src/base/ftgasp.c
    src/base/ftglyph.c
    src/base/ftgxval.c
    src/base/ftlcdfil.c
    src/base/ftmm.c
    src/base/ftotval.c
    src/base/ftpatent.c
    src/base/ftpfr.c
    src/base/ftstroke.c
    src/base/ftsynth.c
    src/base/fttype1.c
    src/base/ftwinfnt.c
    src/base/ftxf86.c
    src/truetype/truetype.c
    src/type1/type1.c
    src/cff/cff.c
    src/cid/type1cid.c
    src/pfr/pfr.c
    src/type42/type42.c
    src/winfonts/winfnt.c
    src/pcf/pcf.c
    src/bdf/bdf.c
    src/sfnt/sfnt.c
    src/autofit/autofit.c
    src/pshinter/pshinter.c
    src/raster/raster.c
    src/smooth/smooth.c
    src/cache/ftcache.c
    src/gzip/ftgzip.c
    src/lzw/ftlzw.c
    src/bzip2/ftbzip2.c
    src/psaux/psaux.c
    src/psnames/psmodule.c)

include_directories("src/truetype")
include_directories("src/sfnt")
include_directories("src/autofit")
include_directories("src/smooth")
include_directories("src/raster")
include_directories("src/psaux")
include_directories("src/psnames")

add_library(freetype SHARED ${BASE_SRCS})

set(FREETYPE_LIBRARY freetype CACHE STRING "The FreeType library name")
set(FREETYPE_FOUND TRUE CACHE BOOL "Whether freetype has been found or not")
set(FREETYPE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/
    ${PROJECT_SOURCE_DIR}/include/freetype CACHE STRING "FreeType include
    directories")

    set(FREETYPE_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include/
    ${PROJECT_SOURCE_DIR}/include/freetype CACHE STRING "FreeType include
    directories")</pre>
<p>The file sets the variables that FindFreeType.cmake sets, so any dependent sub-projects should use this first. Just remember to use:</p>
<pre># Build FreeType
add_subdirectory(lib/freetype-2.4.8)
include_directories(lib/freetype-2.4.8/include)</pre>
<p>&#8230; before building the dependent projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2011/12/cross-compiling-freetype-for-android-with-cmake/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building Boost 1.47 for Android using CMake and the NDK</title>
		<link>http://www.mfoot.com/2011/12/building-boost-1-47-for-android-using-cmake-and-the-ndk/</link>
		<comments>http://www.mfoot.com/2011/12/building-boost-1-47-for-android-using-cmake-and-the-ndk/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 14:52:32 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android-cmake]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[cmake]]></category>
		<category><![CDATA[NDK]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=256</guid>
		<description><![CDATA[The Boost library is incredibly useful in cross-platform C++ software development. Building Boost for Android can be a bit troublesome and several patches need to be applied to the code. Mystic Games provides a project on GitHub called Boost for &#8230; <a href="http://www.mfoot.com/2011/12/building-boost-1-47-for-android-using-cmake-and-the-ndk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The <a title="Boost" href="http://www.boost.org/">Boost library</a> is incredibly useful in cross-platform C++ software development. Building Boost for Android can be a bit troublesome and several patches need to be applied to the code. Mystic Games provides a project on GitHub called <a title="Boost for Android - Github" href="https://github.com/MysticTreeGames/Boost-for-Android">Boost for Android</a> which at the time of writing worked with official NDK r5c and Boost version 1.45. See after the break for more information.</p>
<p><span id="more-256"></span>Version 1.47 adds some useful modules such as Boost::Random and Boost::Asio, but the patches from 1.45 don&#8217;t apply. Luckily klayge.org has applied the patches manually (there aren&#8217;t many).</p>
<h2>Patching Boost:</h2>
<ul>
<li>The patched Boost 1.47 files <a title="Boost 1.47 Android NDK r6" href="http://www.klayge.org/2011/11/02/compile-boost-1-47-with-android-ndk-r6/">here</a>.</li>
<li>The Boost 1.47 source <a title="Boost 1.47 Download" href="http://www.boost.org/users/history/version_1_47_0.html">here</a>.</li>
<li><a title="Android-cmake - Google Code" href="android-cmake.googlecode.com">android-cmake</a> installed and configured to use your NDK toolchain.</li>
</ul>
<p><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">First, merge (don&#8217;t replace!) the </span><em style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">boost</em><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"> and </span><em style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">libs</em><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"> folders from the download into the boost directory. You now have a patched version of Boost. Paste the contents of the code below into a file called CMakeLists.txt inside the <em>boost</em> directory. This is a modified version of android-cmake&#8217;s Boost installation script that allows you to either build and install Boost to your NDK directory or build it as a dependency for a project (this has the advantage of being sure you&#8217;re using the same version of Boost on each machine you build on and for each architecture, as well as meaning you don&#8217;t need to manually install Boost on each development machine, but Boost is a very large dependency to add and it is a lot of files to place into a repository).</span></p>
<pre>cmake_minimum_required(VERSION 2.8)

project(android-boost)

#find patched boost directory
set(BOOST_ROOT ${PROJECT_SOURCE_DIR} CACHE PATH  "Boost 1.47.0 patched for android")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -DNO_BZIP2" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_BZIP2")

include_directories(${PROJECT_SOURCE_DIR})

# Build each of the Boost libraries that have compiled components
file(GLOB lib_srcs ${PROJECT_SOURCE_DIR}/libs/system/src/*.cpp)

add_library( boost_system ${lib_srcs})

file(GLOB lib_srcs ${PROJECT_SOURCE_DIR}/libs/filesystem/v2/src/*.cpp)

add_library( boost_filesystem ${lib_srcs})

set(lib_dir ${PROJECT_SOURCE_DIR}/libs/iostreams/src)
set(lib_srcs ${lib_dir}/file_descriptor.cpp   ${lib_dir}/gzip.cpp   ${lib_dir}/mapped_file.cpp   ${lib_dir}/zlib.cpp)
add_library( boost_iostreams ${lib_srcs})

file(GLOB lib_srcs ${PROJECT_SOURCE_DIR}/libs/program_options/src/*.cpp)

add_library( boost_program_options ${lib_srcs})

file(GLOB lib_srcs ${PROJECT_SOURCE_DIR}/libs/regex/src/*.cpp)

add_library( boost_regex ${lib_srcs})

file(GLOB lib_srcs ${PROJECT_SOURCE_DIR}/libs/signals/src/*.cpp)

add_library( boost_signals ${lib_srcs})

file(GLOB lib_srcs ${PROJECT_SOURCE_DIR}/libs/thread/src/pthread/*.cpp)

add_library( boost_thread ${lib_srcs})

set(BOOST_ROOT ${PROJECT_SOURCE_DIR} CACHE PATH "Path to the Boost root directory")
set(BOOST_INCLUDEDIR ${BOOST_ROOT} CACHE PATH "Boost include directory")
set(Boost_INCLUDE_DIRS ${BOOST_ROOT} CACHE PATH "Boost header locations")
set(Boost_LIBRARIES boost_filesystem boost_system boost_program_options
boost_iostreams boost_regex boost_signals boost_thread  CACHE STRING "khkh")

configure_file(${PROJECT_SOURCE_DIR}/BoostConfig.cmake.in
${PROJECT_BINARY_DIR}/BoostConfig.cmake @ONLY)

install(DIRECTORY ${BOOST_ROOT}/boost DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS boost_system DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS boost_filesystem DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS boost_program_options DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS boost_iostreams DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS boost_regex DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS boost_signals DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS boost_thread DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)</pre>
<p>Optional: You can then also add Boost 1.47&#8242;s version number to the known versions in FindBoost.cmake (Boost 1.47 is newer than CMake 2.8 that I am using):</p>
<pre>  set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
    <strong>"1.47.0" "1.47"</strong> "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42"</pre>
<h2>Option: Building Boost for the NDK</h2>
<p>You can then either open a terminal and build Boost using android-cmake and install to the NDK directory:</p>
<pre>$ cd boost_1_47/
$ mkdir build
$ cd build/
$ android-cmake ..
$ make
$ sudo make install</pre>
<p>Boost should now be able to be found by CMake with the standard find_package command:</p>
<pre>find_package(Boost 1.47 COMPONENTS filesystem system thread REQUIRED)</pre>
<h2>Alternative: Adding Boost as a sub-project in CMake</h2>
<p>If you move the boost directory into your third party library directory you can then build boost and be sure you have the correct version all of the time by adding this to your project&#8217;s CMakeLists.txt file:</p>
<pre># Build boost 1.47
add_subdirectory(lib/boost_1_47)</pre>
<p>Just remember to link against ${Boost_LIBRARIES} and include ${Boost_INCLUDE_DIRS} as you usually would.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2011/12/building-boost-1-47-for-android-using-cmake-and-the-ndk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes on Android Graphics and Animations</title>
		<link>http://www.mfoot.com/2011/12/notes-on-android-graphics-and-animations/</link>
		<comments>http://www.mfoot.com/2011/12/notes-on-android-graphics-and-animations/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 13:34:33 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://www.mfoot.com/?p=244</guid>
		<description><![CDATA[This post contains my notes on the Youtube Video &#8220;Learn about Android Graphics &#38; Animations from Google&#8217;s Android UI Toolkit Team&#8221; which shows a talk given by Romain Guy and Chet Haase from Google at the San Francisco Android User &#8230; <a href="http://www.mfoot.com/2011/12/notes-on-android-graphics-and-animations/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post contains my notes on the Youtube Video &#8220;<a title="Learn about Android Graphics &amp; Animations from Google's Android UI Toolkit team" href="http://www.youtube.com/watch?v=duefsFTJXzc">Learn about Android Graphics &amp; Animations from Google&#8217;s Android UI Toolkit Team</a>&#8221; which shows a talk given by Romain Guy and Chet Haase from Google at the San Francisco Android User Group, Nov 20th 2010. Note that at the time of writing the video is already quite old, but much of it is still relevant and it&#8217;s well worth a watch for anybody interested in working with graphics in Android. This post is partly for me to remember and refer back to, but hopefully others will find it useful. The video is embedded below and notes can be found after the break:</p>
<p><iframe width="584" height="329" src="http://www.youtube.com/embed/duefsFTJXzc?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><span id="more-244"></span>So, summary of the video:</p>
<ul>
<li><strong>Surface</strong> is the name for the buffer that objects are rendered into, whether on-screen or off-screen.</li>
<li>05:23: <strong>PixelFlinger</strong> is the equivalent of a JIT for the software implementation of OpenGL that&#8217;s used in the Android emulator. This is pretty interesting, it generates assembly code at runtime based on what render operations you&#8217;re performing.</li>
<li>06:00: <strong>View</strong>s are the basic UI components, for instance each of the UI widgets inherits from View. <strong>ViewGroup</strong>s contain zero or more views and provide the base class for layouts and view containers, allowing you to modify the contents of the container and set properties for how the view children are displayed. <strong>SurfaceView</strong>s are special Views that allow you to place Surfaces at certain points in the screen. Android also provides classes such as the <a href="http://developer.android.com/reference/android/opengl/GLSurfaceView.html">GLSurfaceView</a> which enables OpenGL to render into the Surface and the <a href="http://developer.android.com/reference/android/widget/VideoView.html">VideoView</a> which allows videos to be rendered as well as providing video playback controls.</li>
<li>06:40 Applications can render via a Canvas (which uses Google&#8217;s Skia library) or via RenderScript (which currently makes OpenGL calls) or via OpenGL directly. Each rendering method eventually renders onto the specified kind of Surface.</li>
<li>07:25 Android supports OpenGL ES 1.x and 2.0, and you can use either of these on a device that supports it, early devices and devices running versions before Android 2.2 will not support OpenGL ES 2.0 &#8211; see <a href="https://secure.wikimedia.org/wikipedia/en/wiki/OpenGL_ES#Usage">here</a> for a list of devices that support each version. If you are using the Android Emulator then you will be using PixelFlinger which only supports OpenGL ES 1.x.</li>
<li>08:15 Whenever a frame is drawn, <strong>SurfaceFlinger</strong> produces a composite from each visible View and renders them to a Surface (frame buffer) via either OpenGL or PixelFlinger depending on whether the software GL implementation is being used or not. Older devices used a 2D blitter called MDP.</li>
<li> 09:20 Android won&#8217;t redraw a View unless it&#8217;s both visible and flagged (&#8216;dirty&#8217;) by calling it&#8217;s <a href="http://developer.android.com/reference/android/view/View.html#invalidate()">invalidate()</a> method. This invalidate call will propagate up to any ViewGroups in the view hierarchy to the <strong>ViewRoot</strong> which will lock the Surface of the window and then call draw() on all of it&#8217;s children. When that&#8217;s done the ViewRoot will unlock the canvas and swap the buffers. All windows on Android are double buffered.</li>
<li>15:00 Demo from Chet about how to add animations and effects on Views. Animations can be used for subtle indications &#8211; for instance to indicate whether an image is selected or not it&#8217;s nice to have an animation/transitioning effect rather than an abrupt change in the UI.</li>
<li>16:56 Unlike Java2D, Android&#8217;s Canvas is virtually stateless and uses <strong>Paint</strong>s to specify font size, text colour, colour, opacity, filtering, dithering, anti-aliasing etc. These objects contain a lot of state information and are therefore fairly heavy-weight. Making a new Paint object every frame is not a good idea as you will soon saturate the heap and cause Garbage Collection.</li>
<li>18:15 <strong>Shaders</strong> specify how to draw horizontal or vertical spans of colours (for example different kinds of gradients), i.e. how to fill a shape. These are not the same as GLSL shaders. <strong>ComposeShader</strong> will blend two shaders together and fill the shape with that. <strong>ColorFilter</strong>s perform operations on each pixel they are applied to.</li>
<li>21:00 <strong>XferModes</strong> or blending modes such as Porter-Duff (scientists who defined 12 equations that explain how transparency affects colours) and Darken, Lighten, Multiply and Screen allow modifying the colours of a Canvas. For instance, a BitmapShader and a LinearGradient can be combined with a ComposeShader to draw a bitmap that fades out.</li>
<li>23:17 Demo from Chet showing some example code for using creating new Bitmaps that arise from applying Shaders on Bitmaps. Shaders are created and then the Paint object is told to use that shader. You can then simply draw a rectangle to the screen using the specified Paint and it will perform the shader operations you specified on that rectangle.</li>
<li>25:00<strong> Bitmap</strong>s are either mutable or immutable and have the concept of resolution. Android allows you to specify different assets for different screen resolutions in the same package, and if you place a drawable in the medium resolution folder and are running on a phone which reports itself as high resolution, Android will use that information to scale the Bitmap automatically when it is displayed. Bitmaps can be large objects so they can be recycled without having to wait for the garbage collector. Supported Bitmap formats are <strong>ALPHA_8 </strong>(for alpha masks), <strong>ARGB_4444</strong> (this isn&#8217;t recommended, uses 4 bits for each component and therefore doesn&#8217;t look very good), <strong>ARGB_8888</strong> (recommended, 32 bit images, allows for transparency), and <strong>RGB_565</strong> (doesn&#8217;t contain alpha channel, limited precision for colours, faster to draw, uses dithering). JPEG images do not contain transparency and pre-Gingerbread were loaded automatically with RGB_565. <strong>This meant that jpg images automatically lost some quality pre-gingerbread</strong>. Post Gingerbread all images are loaded by default as ARGB_8888 (and application memory usage limits are increased to compensate). When loading a Bitmap, make sure to specify the format that you want, otherwise it will be loaded as it&#8217;s default and every time the Bitmap is drawn it will need to be converted. For instance, pre-Gingerbread the default bit depth for a Surface is 16 bits, so a 32 bit image will need to be converted before rendering which can be slow. You can control quality of this rendering by enabling/disabling dithering on the Paint object and the Drawable object that the Bitmap&#8217;s being used by. Blending should be avoided with the alpha channel. If Android detects an image is completely opaque it can perform a faster rendering pass.</li>
<li>30:00 Demo by Romain showing the effects of precision loss when rendering 32 bit images onto a 16 bit window (introduces artefacts, gradients look banded). Enabling dithering removes the banding somewhat and improves the gradient. Using a 32 bit window ARGB_8888 with no dithering looks fine while ARGB_4444 still looks bad (and hence isn&#8217;t recommended anywhere).</li>
<li>33:10 Slide showing performance comparisons for different bitmap image types on different surfaces. Drawing an ARGB_8888 surface is three times faster on a 32 bit surface than a 16 bit surface. ARGB_4444 is slightly faster than ARGB_8888 on a 16 bit surface. RGB_565 is 12 times faster than ARGB_8888 and 8 times faster than ARGB_4444 when rendering to a 16 bit surface (as it&#8217;s essentially a memcpy on a 16 bit surface) but three times slower than ARGB_8888 and almost twice as slow as ARGB_4444 on a 32 bit surface.</li>
<li>35:50 Demo of two different ways to copy a View into a Bitmap.</li>
<li>37:30 Chet takes over, talks about Animations. Animations enable better user experiences and can help users use the application, especially on smaller screens. The current (as of the talk) SDK has an animation superclass which controls timing, repetition, interpolation and ending states. Nonlinear interpolation on animations such as view sliding is important as it looks much better than linear motion.</li>
<li>40:30 Android allows for Transforming operations (translation, rotation, scale), Fading, Sequences (allowing you to choreograph multiple animations), Cross-fading, and Layout animations (ViewGroups can animate the display of their children via animations rather than displaying them instantly).</li>
<li>41:40 Animations are about making things <em>look animated</em> rather than actually <em>being</em> animated. <strong>This means that moving views via animations doesn&#8217;t actually move the view. </strong>If you move a button, you need to move the actual object afterwards to ensure that it will handle input events for the correct position. This is because the ViewGroup, when rendering it&#8217;s children, detects first if an animation is playing on the child before rendering it. If it is, it renders the current state of the animation rather then the View&#8217;s original settings.</li>
<li>43:16 Fading is done by interpolating alpha values, which again is not the transparency of the View, but the transparency that the View will be drawn with (see previous point).</li>
<li>45:30 Layout animations are based on staggering some template animation for each child of the view.</li>
<li>46:50 With animations you can setDrawingCacheEnabled(True) to allow the animation to represent itself as a Bitmap which means that the animated object doesn&#8217;t need to be re-rendered each frame. This is a large performance increase and is used in Android everywhere transparently. <strong>As soon as a finger touches a view (for example a ScrollView) each of the Views in the ViewGroup are transformed into Bitmaps via setDrawingCacheEnabled which allows them to be scrolled quickly without having to re-render them.</strong> When a Bitmap is off the screen it can be recycled and used by another View.</li>
<li>You can follow Romain Guy at @romainguy and curious-creature.org.</li>
<li>You can follow Chet Haase at @chethaase and graphics-geek.blogspot.com.</li>
</ul>
<div>Slides of this talk can be found at <a href="http://marakana.com/f/212">http://marakana.com/f/212</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mfoot.com/2011/12/notes-on-android-graphics-and-animations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.420 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-19 19:33:38 -->
<!-- Compression = gzip -->
