<?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>#AltDevBlogADay &#187; Erwin Coumans</title>
	<atom:link href="http://www.altdevblogaday.com/author/erwin-coumans/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.altdevblogaday.com</link>
	<description>Each day a little more #gamedev love</description>
	<lastBuildDate>Thu, 17 May 2012 03:06:10 +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>Native Client for Dummies</title>
		<link>http://www.altdevblogaday.com/2011/10/26/native-client-for-dummies/</link>
		<comments>http://www.altdevblogaday.com/2011/10/26/native-client-for-dummies/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 01:33:08 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
				<category><![CDATA[General Interest]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://altdevblogaday.com/?p=19210</guid>
		<description><![CDATA[<p>Today’s Chrome web browser update means you can develop, sell, download and play 3D games written in C++ right from the Chrome Web Store, without plug-in.</p>
<p>This is a quick walk-through on how to develop a basic 3D Native Client app. You can try out my test app from the Chrome Web Store <a href="https://chrome.google.com/webstore/detail/pgehkhceingafmkkmbeoempaablkkeal" target="_blank">here</a> or <a href="https://chrome.google.com/webstore/search/bullet%20physics" target="_blank">here</a>.<br />
<a href="http://www.youtube.com/watch?v=sXNJpdPY9tQ"><img src="http://altdevblogaday.com/wp-content/uploads/2011/10/bullet_native_client-300x187.png" alt="" width="300" height="187" class="aligncenter size-medium wp-image-19234" /></a><br />
Alternatively you can visit http://bulletphysics.org/nacl but in that case you need to enable Native Client by typing <strong>about://flags</strong> in the Chrome address bar. Chrome Web Store Native Client apps don&#8217;t require flags.</p>
<p><a href="http://www.altdevblogaday.com/2011/10/26/native-client-for-dummies/" class="more-link">Read more on Native Client for Dummies&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Today’s Chrome web browser update means you can develop, sell, download and play 3D games written in C++ right from the Chrome Web Store, without plug-in.</p>
<p>This is a quick walk-through on how to develop a basic 3D Native Client app. You can try out my test app from the Chrome Web Store <a href="https://chrome.google.com/webstore/detail/pgehkhceingafmkkmbeoempaablkkeal" target="_blank">here</a> or <a href="https://chrome.google.com/webstore/search/bullet%20physics" target="_blank">here</a>.<br />
<a href="http://www.youtube.com/watch?v=sXNJpdPY9tQ"><img src="http://altdevblogaday.com/wp-content/uploads/2011/10/bullet_native_client-300x187.png" alt="" width="300" height="187" class="aligncenter size-medium wp-image-19234" /></a><br />
Alternatively you can visit http://bulletphysics.org/nacl but in that case you need to enable Native Client by typing <strong>about://flags</strong> in the Chrome address bar. Chrome Web Store Native Client apps don&#8217;t require flags.</p>
<p>Either way, make sure your Chrome About Box shows version 15 or later.</p>
<p>Some features of the simple test app:</p>
<ul>
<li>OpenGL ES2 3D rendering with textures</li>
<li>Mouse interaction</li>
<li>Load binary files using a file chooser</li>
<li>Use of middleware: Bullet Physics, libjpeg</li>
</ul>
<h4>Download the SDK</h4>
<p>You can download the Native Client SDK and all tutorial and build system files in a single self-contained <a href="https://github.com/downloads/erwincoumans/experiments/experiments_nacl_2.zip">zip file here</a> (64 MB). It should work out-of-the-box under Windows. This tutorial also builds under Linux or Mac OSX but that is left as an exercise for the reader (or leave a comment for help).</p>
<h4>Setup your build system</h4>
<p>Just unzip the <a href="https://github.com/downloads/erwincoumans/experiments/experiments_nacl_2.zip">zip file</a>  (64 MB) <strong>in a folder without spaces in the name</strong> and you are all set to go under Windows.</p>
<p>The Native Client SDK comes with a gcc-based compiler toolchain. You need to tell your build system the location of the C compiler (CC), C++ compiler (CXX) and linker (AR). Above zip file includes make.exe and Makefiles that work under Windows out-of-the-box. There is no need to install Cygwin or MinGW. I used premake to generate the Makefiles.</p>
<h4>Add some salt and pepper</h4>
<p>An API called Pepper is used to provide hooks between Native Client and web browser services such as HTML5 and 3D. This test application was a port from a simple Win32 application. I used the Tumbler NaCl example as a starting point. The original version is located in <strong>build\nacl\nacl_sdk\pepper_15\examples\tumbler</strong>. In order to ‘port’ it to Native Client in a web page, the following changes were made. Most of the source code is shared and portable, to make debugging easier.</p>
<ul>
<li>Program entry point: The Windows application used WinMain as a program entry point. For Native Client the entry point is the constructor of your module.</li>
<li>All of the OpenGL ES initialization of matrices, shaders, textures, vertex and index buffers are the same, except for creating the context.</li>
<li>Keyboard and mouse input. Instead of a Windows event you register for keyboard and/or mouse events and implement the event callback.</li>
<li>Loading files from the local file system is not possible for obvious security reasons, so there is no ‘fopen’ command. You can let the user pick a file using the browsers build-in File Chooser, load the file in memory and use Javascript to pass the file to the Native Client module. Binary files can be base64 encoded by the browser, and decoded by your Native Client code. This works well in practice. In the future you can call the File Chooser directly from NaCl C++ code.</li>
</ul>
<h4>Build the executable</h4>
<p>Click on <strong>build/nacl.bat</strong> and wait. Here is the content of the batch file:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">set NACL_TARGET_PLATFORM=pepper_15
set NACL_SDK_ROOT=%CD%/nacl/nacl_sdk
&nbsp;
premake4 --with-nacl gmake
cd nacl
&nbsp;
set AR=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%\toolchain\win_x86_newlib\bin\x86_64-nacl-ar.exe
set CC=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%\toolchain\win_x86_newlib\bin\x86_64-nacl-gcc.exe
set CXX=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%\toolchain\win_x86_newlib\bin\x86_64-nacl-g++.exe
&nbsp;
set config=release32
make
&nbsp;
set config=release64
make</pre></div></div>

<p>This builds two Native Client executables, 32bit x86 and 64bit x64, they are located in build\nacl\nginx-1.1.2\html\NativeClientTumbler.exe and build\nacl\nginx-1.1.2\html\NativeClientTumbler_64.exe<br />
The web page know how to load this module using a manifest file called <a href="https://github.com/erwincoumans/experiments/blob/master/build/nacl/nginx-1.1.2/html/tumbler.nmf" target="_blank">tumbler.nmf</a> :</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">{
  &quot;program&quot;: {
    &quot;x86-64&quot;: {&quot;url&quot;: &quot;NativeClientTumbler_x64.exe&quot;},
    &quot;x86-32&quot;: {&quot;url&quot;: &quot;NativeClientTumbler.exe&quot;}
  }
}</pre></div></div>

<p>The index.html web page can load the Native Client code using this tumbler.nmf file. Check out <a href="https://github.com/erwincoumans/experiments/blob/master/build/nacl/nginx-1.1.2/html/index.html#L129">index.html</a> and <a href="https://github.com/erwincoumans/experiments/blob/master/build/nacl/nginx-1.1.2/html/tumbler.js#L128">tumbler.js</a> for details.</p>
<h4>Test the application</h4>
<p>Click on build/nacl_runtest.bat and confirm that the nginx web browser is allowed to wait for connections. </p>
<p>Native Client applications hosted in the Chrome Web Store should run without special flags or settings. In order to run NaCl modules in web pages outside of the Store you need to enable Native Client manually. Just type <strong>about://flags</strong> in the Chrome address bar and enable the Native Client setting.</p>
<p>Now open Chrome and type http://localhost/index.html and if all goes well you can play your app.</p>
<h4>Debug the application</h4>
<p>You can use ‘printf’ debugging using the Javascript console, but in most cases it is easier to maintain a Windows version and perform debugging under Visual Studio. You can compile the tutorial under Visual Studio by clicking on the build/vs2008.bat file and open the GLES2_BulletBlendReader_Angle project. This project emulates OpenGL ES2 under Windows using a DirectX wrapper called <a href="http://code.google.com/p/angleproject" target="_blank">Angle</a>.</p>
<h4>Deploy to the Chrome Web Store</h4>
<p>You can make your C++ Native Client module available for free or for sale in the Chrome Web Store. A one-time registration fee of just 5$ is used, probably to stop spam. You have to create a manifold.json that provides the information about your application. This includes the name, description and where the web page and assets are located. Here is the manifest used for this tutorial:</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">{
    &quot;name&quot;: &quot;Bullet Physics NaCl Test&quot;,
    &quot;version&quot;: &quot;0.8&quot;,
    &quot;description&quot;: &quot;This Native Client module runs a C++ Bullet Physics simulation.&quot;,
    &quot;app&quot;: {
	    &quot;launch&quot;: {
	       &quot;local_path&quot;: &quot;index.html&quot;
	    }
	  },
	  &quot;icons&quot;: {
	  &quot;16&quot;: &quot;bullet_icon16.png&quot;,
      &quot;128&quot;: &quot;bullet_icon128.png&quot;
    }
}</pre></div></div>

<h4>Notes</h4>
<p>Most of the Google NaCl SDK relies on having Python installed, and I wanted this tutorial to work without external dependencies such as Python, Cygwin or MinGW etc. I used the following replacements:</p>
<ul>
<li>Python was used for the scons build system. I replaced scons by Makefiles, because I think Makefiles are more standard and simpler to adapt to other build systems. I used premake4 to generate the Makefiles to keep it self-contained.</li>
<li>Python was also used to download and update the Native Client SDK. To avoid this, the zip file already contains the Native Client SDK and the build system knows its location. If you have Python installed you can still run this updater, it is located under <strong>build\nacl\nacl_sdk\update_naclsdk.bat</strong> in the <a href="https://github.com/downloads/erwincoumans/experiments/experiments_nacl_2.zip">zip file</a>.</li>
<li>Finally, Python was used for the web server. I replaced this with the tiny but powerful <a href="http://nginx.org/" target="_blank">nginx </a>web server.</li>
</ul>
<p>I recommend checking out the links below if you are interested to learn more.</p>
<p>Enjoy!</p>
<h4>Useful Links</h4>
<p>http://gonacl.com (it has some links to other middleware that support Native Client such as FMOD, Ogre and Unity)</p>
<p>http://code.google.com/chrome/nativeclient</p>
<p>https://groups.google.com/group/native-client-discuss</p>
<p>http://code.google.com/chrome/webstore/articles/apps_vs_extensions.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/10/26/native-client-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Destruction</title>
		<link>http://www.altdevblogaday.com/2011/09/02/destruction/</link>
		<comments>http://www.altdevblogaday.com/2011/09/02/destruction/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 00:43:55 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
				<category><![CDATA[#gamedev]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://altdevblogaday.com/?p=15359</guid>
		<description><![CDATA[<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/09/angry_rigidbodies.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/angry_rigidbodies-300x123.png" alt="" width="300" height="123" class="aligncenter size-medium wp-image-15405" /></a><br />
I recently organized a <a href="http://bulletphysics.org/siggraph2011">SIGGRAPH course on destruction and dynamics for game and film production</a> and I want to give a quick overview of the topic. Actually it is a quick copy and paste of some of my speakers notes of the introduction, you can check out the course material <a href="http://bulletphysics.org/siggraph2011">here</a>. This is about the simulation part of breaking objects, not so much about the rendering. To be honest, I&#8217;m still learning about this sub-topic so if you have some experience in this area, please let us know in the comments.</p>
<p><a href="http://www.altdevblogaday.com/2011/09/02/destruction/" class="more-link">Read more on Destruction&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/09/angry_rigidbodies.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/angry_rigidbodies-300x123.png" alt="" width="300" height="123" class="aligncenter size-medium wp-image-15405" /></a><br />
I recently organized a <a href="http://bulletphysics.org/siggraph2011">SIGGRAPH course on destruction and dynamics for game and film production</a> and I want to give a quick overview of the topic. Actually it is a quick copy and paste of some of my speakers notes of the introduction, you can check out the course material <a href="http://bulletphysics.org/siggraph2011">here</a>. This is about the simulation part of breaking objects, not so much about the rendering. To be honest, I&#8217;m still learning about this sub-topic so if you have some experience in this area, please let us know in the comments.</p>
<p>A typical destruction process can be divided in two parts:</p>
<ol>
<li>the preparation of the 3D geometry, usually done during the creation of a game
</li>
<li>the breaking of objects when playing the game
</ol>
<p>There are many different ways to prepare the 3D geometry for fracture. Often this involves 3D content creation tools such as Autodesk Maya, 3ds Max or the open source Blender 3D modeler.</p>
<h4>Voronoi shatter</h4>
<p>Cutting a 3D model into pieces using voronoi shatter is very popular. For example it is used by the Epic Unreal Engine. You first create particles inside the 3D model. Then you create Voronoi regions that enclose those points. Some good algorithms are developed to compute voronoi regions efficiently, given a closed mesh and enclosed points, for example Fortune&#8217;s algorithm.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/09/voronoi.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/voronoi-300x118.png" alt="" width="300" height="118" class="aligncenter size-medium wp-image-15363" /></a></p>
<h4>Tetrahedralization</h4>
<p>It is also possible to subdivide the original 3d model into a set of tetrahedra, this process is also called a tetrahedralization. It can be done using Delaunay Triangulation, which is the dual of voronoi regions. There are some open source libraries that can perform this task, such as <a href="http://sourceforge.net/projects/netgen-mesher">Netgen</a>, <a href="http://tetgen.berlios.de">Tetgen </a>and <a href="http://www.cgal.org">CGal</a> for example. It is a complicated process, but there is also a much simpler approximation, explained in page 18 of the notes of the excellent <a href="http://www.matthiasmueller.info">real-time physics</a> SIGGRAPH course.<br />
<a href="http://altdevblogaday.com/wp-content/uploads/2011/09/tetrahedralization.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/tetrahedralization-300x129.png" alt="" width="300" height="129" class="aligncenter size-medium wp-image-15392" /></a></p>
<h4>Boolean operations</h4>
<p>Boolean operations, also known as constructive solid geometry (CSG) is a way to perform volumetric operations between 3D models. For example you can add two volumes together, or compute the difference between two objects, or take the intersection. Those operations allow you to break original 3D models into smaller pieces, similar to a cookie cutter.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/09/booleans1.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/booleans1-300x127.png" alt="" width="300" height="127" class="aligncenter size-medium wp-image-15387" /></a></p>
<h4>Cutting, slicing etc</h4>
<p>Of course there are many other methods to generate a pre-fractured model, for example an artist can create the parts by hand, or some slicing algorithm can be applied based on polygon clipping.</p>
<p>As this is just a short overview, let&#8217;s move on to the runtime breaking methods. Aside from triggering a pre-recorded animation of a destruction sequence, some common approaches are:</p>
<h4>Real-time booleans</h4>
<p>The Red Faction games by Volition showed some cool destruction in their worlds. Their <a href="http://en.wikipedia.org/wiki/Geo-Mod">Geo Mod</a> technology is based on the application of real-time boolean operations. Recently I encouraged Stan Melax to open source his real-time booleans demo, so you can check it out at <a href="http://melax.googlecode.com">http://melax.googlecode.com</a>. Here is a screenshot:<br />
<a href="http://altdevblogaday.com/wp-content/uploads/2011/09/realtime_booleans.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/realtime_booleans-300x162.png" alt="" width="300" height="162" class="aligncenter size-medium wp-image-15396" /></a><br />
The actual boolean operations are based on the merging of BSP trees, as described by Bruce Naylor, <a href="http://namcub.accela-labs.com/pdf/Merging%20BSP%20trees%20yields%20polyhedral%20set%20operations%20-%20Naylor.pdf">see the pdf here</a>. Although the technique allows a lot of freedom to destroy the environment, it requires an additional physics system to analyse if buildings need to collapse.</p>
<h4>Finite element method</h4>
<p>The Finite Element Method (FEM) uses continuum mechanics to simulate deformation and fracture. There are several ways of implementing FEM, either using explicit integration or implicit integration. Recomputing the stiffness matrix every simulation frame can be very expensive, and stiffness warping avoids this by using a corotational mapping. Such corotational FEM method is used by Pixelux Digital Molecular Matter (DMM) in Lucas Arts Star Wars games, as described in this <a href="http://graphics.berkeley.edu/papers/Parker-RTD-2009-08/index.html">SIGGRAPH paper</a>. I recently extracted an open source implementation from the Open Tissue physics library. You can grab the source code from my <a href="https://github.com/erwincoumans/experiments">github repository</a> it is in the dynamics/corotational_fem folder, here is a screenshot:<br />
<a href="http://altdevblogaday.com/wp-content/uploads/2011/09/fem.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/fem-300x151.png" alt="" width="300" height="151" class="aligncenter size-medium wp-image-15402" /></a><br />
Some researchers in Inria, France, accelerated FEM on the GPU using CUDA, and it could simulate 47k tetrahedra at over 200 frames per second on a modern GPU. Their source code is hidden in a SVN repository of the Sofa framework ( svn checkout svn://scm.gforge.inria.fr/svn/sofa/branches/Sofa-1.0 )</p>
<h4>Breakable composit rigid body</h4>
<p>Some games use a plain rigid body dynamics engine for destruction, such as Angry Birds, which uses the open source Box2d engine. In many cases you want more control over the destruction effect.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/09/composit_rigidbody.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/composit_rigidbody-300x125.png" alt="" width="300" height="125" class="aligncenter size-medium wp-image-15409" /></a></p>
<p>Here are some steps that describe the composite rigid body fracture method. First we prepare the geometry into fractured pieces and now we need to &#8216;glue&#8217; them together. We need to create some connections between those pieces. There are several ways to do this. One way is to define connections between every piece and every other piece. This gives the most control, but the performance can be slow due to the many connections. Another way to compute connections is to automatically compute them based on collision detection: compute the contact points between touching pieces,  and only create connections when there is a contact point. Then you can create a breaking threshold for those connections.</p>
<p>Once we glued the pieces into a single rigid body, we can perform the runtime fracture. If there is a collision impact, we compute the impulse. If this impulse is larger than a chosen threshold, we propagate this impulse through the connections. Those connections can be weakened or broken.</p>
<p>After this, we need to determine the disconnected parts, we use the union find algorithm for this, and then create new rigid bodies for each separate part. Of course the inertia matrix needs to be updated properly. In our open source <a href="http://bullet.googlecode.com">Bullet physics library</a> there is a demo that shows how to implement this, it is under Bullet/Demos/BulletFractureDemo.</p>
<h4>Breakable rigid body constraints</h4>
<p>We can also simulate the object by using a rigid body for each fracture piece, and connect the pieces using breakable constraints.</p>
<p>For example this can be a fixed rigid body constraint that connects two pieces. You can see that the object is bending a little bit after the collision, because the constraints are not perfectly stiff. This bending effect can be desired in some cases, and this method has been used in some games and movies.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/09/breakable_constraints.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/09/breakable_constraints-300x150.png" alt="" width="300" height="150" class="aligncenter size-medium wp-image-15416" /></a></p>
<h4>Hybrid and other methods</h4>
<p>It is also possible to use a combination of different methods. For example you can use FEM to determine when and where to break and use rigid body simulation to simulate the broken pieces as described in this <a href="http://www.matthiasmueller.info/publications/fracture.pdf">paper</a> (pdf).</p>
<p>If you have any experience or thoughts of fracture and destruction in games, please reply!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/09/02/destruction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing Android Apps using Visual Studio</title>
		<link>http://www.altdevblogaday.com/2011/07/26/writing-android-apps-using-visual-studio/</link>
		<comments>http://www.altdevblogaday.com/2011/07/26/writing-android-apps-using-visual-studio/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 20:24:05 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://altdevblogaday.com/?p=12464</guid>
		<description><![CDATA[<p><a href="http://www.wingdb.com/wgMobileEdition.htm"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/android_wingdb_visual_studio.png" alt="" width="205" height="142" class="aligncenter size-full wp-image-12584" /></a><br />
Google has made it unnecessarily complicated to write Android apps under Windows for C++ developers who are used to Visual Studio. Hopefully this posting makes it easier.</p>
<p>This article is about setting up your Android development environment in combination with Visual Studio and <a href="http://www.wingdb.com/wgMobileEdition.htm">WinDBG for mobile systems beta</a>. The result is that you can create and debug Android projects from within Visual Studio on emulator and the actual device (that doesn&#8217;t need to rooted). Those project files are kept in sync with the original NDK build files (Android.mk etc) so they are compatible with the command-line tools. In other words, you can still use ndk-build and ant. If you are a happy Eclipse user, this posting isn’t for you.</p>
<p><a href="http://www.altdevblogaday.com/2011/07/26/writing-android-apps-using-visual-studio/" class="more-link">Read more on Writing Android Apps using Visual Studio&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wingdb.com/wgMobileEdition.htm"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/android_wingdb_visual_studio.png" alt="" width="205" height="142" class="aligncenter size-full wp-image-12584" /></a><br />
Google has made it unnecessarily complicated to write Android apps under Windows for C++ developers who are used to Visual Studio. Hopefully this posting makes it easier.</p>
<p>This article is about setting up your Android development environment in combination with Visual Studio and <a href="http://www.wingdb.com/wgMobileEdition.htm">WinDBG for mobile systems beta</a>. The result is that you can create and debug Android projects from within Visual Studio on emulator and the actual device (that doesn&#8217;t need to rooted). Those project files are kept in sync with the original NDK build files (Android.mk etc) so they are compatible with the command-line tools. In other words, you can still use ndk-build and ant. If you are a happy Eclipse user, this posting isn’t for you.</p>
<p>There is an open source project called <a href="http://code.google.com/p/vs-android/">vs-android</a> that integrates Android with Visual Studio, but it doesn&#8217;t support debugging as far as I know.</p>
<p>Before we can install WinGDB we need to have the NDK in working order. Google don’t provide a single installer for their NDK. Instead they ask developers to gather all information and installers from various websites. Many things can go wrong this way. On top of that, their 64bit NDK installer has a bug that doesn’t find the Java installation path until you hit “back/next”. Steps 1 to 6 below deals with installing the NDK.</p>
<p>If you already have a working recent NDK environment you can skip to step 7 for WinGDB.</p>
<p>1) Download the JDK from the Oracle website after accepting the agreement, the current version is jdk-6u26-windows-x64.exe</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/jdk_jre.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/jdk_jre-300x228.png" alt="" width="300" height="228" class="aligncenter size-medium wp-image-12546" /></a></p>
<p>Install the JDK to C:\Program Files\Java\jdk1.6.0_26\ and install JRE to C:\Program Files\Java\jre6\ and make sure java.exe is in your path.</p>
<p>2) Download Apache Ant apache-ant-1.8.2-bin.zip from the http://ant.apache.org/ website and<br />
unzip it to c:\android\apache-ant-1.8.2-bin\</p>
<p>3) Download Android SDK from http://developer.android.com/sdk/index.html, for example this recent installer installer_r12-windows.exe</p>
<p>Run the installer.<br />
It might complain that the JDK is not found:</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/android_not_found.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/android_not_found-300x233.png" alt="" width="300" height="233" class="aligncenter size-medium wp-image-12550" /></a></p>
<p>Just hit the Back button and Next:</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/found.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/found-300x233.png" alt="" width="300" height="233" class="aligncenter size-medium wp-image-12551" /></a></p>
<p>Hit next and choose your destination path. I changed it from<br />
C:\Program Files (x86)\Android\android-sdk to C:\Android\android-sdk to keep the SDKs together.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/sdk_complete.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/sdk_complete-300x233.png" alt="" width="300" height="233" class="aligncenter size-medium wp-image-12554" /></a></p>
<p>4) Start the SDK manager</p>
<p>Your choice of packages depends which Android versions you target for your App. You can just select the default set, it might take a while to download though.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/sdk_manager.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/sdk_manager-300x233.png" alt="" width="300" height="233" class="aligncenter size-medium wp-image-12555" /></a></p>
<p>5) Download the Android NDK android-ndk-r6-windows.zip and unzip it in c:\android.</p>
<p>6) Install Cygwin from http://cygwin.com/install.html using <a href="http://cygwin.com/setup.exe">setup.exe</a></p>
<p>Install Cygwin to the default location, c:\cygwin and select a mirror</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/cygwin_setup.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/cygwin_setup-300x219.png" alt="" width="300" height="219" class="aligncenter size-medium wp-image-12556" /></a></p>
<p>Make sure to select the &#8216;make&#8217; tool by searching for &#8216;make&#8217; and enabling &#8216;install&#8217; for the &#8216;Devel&#8217; packages:</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/cygwin.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/cygwin-300x219.png" alt="" width="300" height="219" class="aligncenter size-medium wp-image-12549" /></a></p>
<p>7) Download WinGDB from http://www.wingdb.com/wgMobileEdition.htm, currently the beta version is WinGDB-2.0-b1006-mse.msi</p>
<p>8)Run the WinDBG installer</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/windbg_installer.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/windbg_installer-300x245.png" alt="" width="300" height="245" class="aligncenter size-medium wp-image-12561" /></a></p>
<p>Then configure WinGDB using the WinGDB preferences tab in Visual Studio</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/wingdb_tab.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/wingdb_tab.png" alt="" width="634" height="249" class="aligncenter size-full wp-image-12574" /></a></p>
<p>and set the directories where you install/unzipped the packages in previous steps:</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/windbg_preferences2.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/windbg_preferences2.png" alt="" width="681" height="508" class="aligncenter size-full wp-image-12577" /></a></p>
<p>9) Create a new Android project in Visual Studio</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/new_android_project.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/new_android_project-300x166.png" alt="" width="300" height="166" class="aligncenter size-medium wp-image-12563" /></a></p>
<p>and choose the name and target</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/new_android_project2.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/new_android_project2-300x123.png" alt="" width="300" height="123" class="aligncenter size-medium wp-image-12564" /></a></p>
<p>Once the project is created, change some project properties</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/project_properties.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/project_properties-247x300.png" alt="" width="247" height="300" class="aligncenter size-medium wp-image-12568" /></a></p>
<p>and change the debug target to device. You can also leave it to use the emulator, but I find it too sluggish.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/new_android_project31.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/new_android_project31-300x201.png" alt="" width="300" height="201" class="aligncenter size-medium wp-image-12569" /></a></p>
<p>10) Connect your Android device and make sure the USB drivers are installed. For my Asus TF101 the USB drivers were automatically installed</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/asus_tf101_usb.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/asus_tf101_usb.png" alt="" width="536" height="243" class="aligncenter size-full wp-image-12580" /></a></p>
<p>Enable USB debugging on your Android device, put some breakpoint in your main.cpp and hit F7 or F5 within Visual Studio and if all goes well:</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/debugging_visual_studio_tf1011.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/debugging_visual_studio_tf1011-300x235.png" alt="" width="300" height="235" class="aligncenter size-medium wp-image-12581" /></a></p>
<p>If the connection doesn&#8217;t work, you could try disabling your firewall and/or anti-virus scanner. Another option is to enable the Pipe method instead of TCP/IP:</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/07/pipe.png"><img src="http://altdevblogaday.com/wp-content/uploads/2011/07/pipe-300x85.png" alt="" width="300" height="85" class="aligncenter size-medium wp-image-12616" /></a></p>
<p>WinGDB also supports import of existing Android projects, but your mileage might vary. If it works for you (or not), please leave a comment.</p>
<p>Note that WinGDB mobile edition is still in beta, so please report problems to <a href="http://www.wingdb.com/wgContact.htm">their support</a> or <a href="http://www.wingdb.com/forum/">forums</a>. I ran into a few issues that hopefully get sorted in the final version of WinGDB, but I find the free beta already useful enough to try it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/07/26/writing-android-apps-using-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenCL interop tutorial: update the world transform of instanced meshes on the GPU</title>
		<link>http://www.altdevblogaday.com/2011/06/11/a-short-opencl-tutorial-updating-world-transforms-of-instanced-meshes-on-the-gpu/</link>
		<comments>http://www.altdevblogaday.com/2011/06/11/a-short-opencl-tutorial-updating-world-transforms-of-instanced-meshes-on-the-gpu/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 19:56:05 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
		
		<guid isPermaLink="false">http://altdevblogaday.org/?p=8224</guid>
		<description><![CDATA[<p>&#160;</p>
<p>Previously I blogged here about convex collision detection using the separating axis test and Sutherland Hodgeman clipping. In a few upcoming blog postings I want to discuss how to perform the collision detection and simple particle/rigid body dynamics on the GPU for fun.</p>
<p><a href="http://www.altdevblogaday.com/2011/06/11/a-short-opencl-tutorial-updating-world-transforms-of-instanced-meshes-on-the-gpu/" class="more-link">Read more on OpenCL interop tutorial: update the world transform of instanced meshes on the GPU&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Previously I blogged here about convex collision detection using the separating axis test and Sutherland Hodgeman clipping. In a few upcoming blog postings I want to discuss how to perform the collision detection and simple particle/rigid body dynamics on the GPU for fun.</p>
<p><a href="http://altdevblogaday.com/wp-content/uploads/2011/06/interop.png"><img class="aligncenter size-full wp-image-8236" src="http://altdevblogaday.com/wp-content/uploads/2011/06/interop.png" alt="" width="636" height="520" /></a></p>
<p>&nbsp;</p>
<p>The result of rigid body dynamics is a world transform for each object: the position and orientation. The world position and the orientation (represented as a quaternion) can both be stored as a float4/Vector4 when we use 16-byte alignment.</p>
<p>We could render individual objects on the GPU by making calls to the OpenGL or Direct3D API from the CPU side, updating the world transform for each object and rendering them one by one.</p>
<p>If we run the particle or rigid body simulation on the GPU, this means that we have to transfer the world transform from GPU to main memory, making the calls on CPU, which transfers those same transforms back to GPU. There is a more efficient way to do this, and this is called OpenCL interop: sharing a single buffer between graphics API and OpenCL. DirectCompute and Direct3D has a similar feature, but in this article we use OpenCL and OpenGL.</p>
<p><strong>Preparation:</strong></p>
<ol>
<li>Store all the transforms in a Vertex Buffer Object (VBO) on the GPU</li>
<li>A GLSL shader that renders instanced meshes using the transforms from this VBO</li>
<li>Initialize OpenCL</li>
</ol>
<p><strong>During the rendering of each frame:</strong></p>
<ol>
<li>call glFinish to make sure the GPU doesn’t access the VBO</li>
<li>Acquire the OpenGL VBO as an OpenCL buffer</li>
<li>Execute some OpenCL kernels that compute and update the transforms in this buffer</li>
<li>Release the OpenCL buffer back to OpenGL</li>
<li>Render all instances using a single call using glDrawElementsInstanced</li>
</ol>
<p>&nbsp;</p>
<p>I’ll briefly go over important bits in the C/C++ implementation for the OpenCL/GL interop, there is link at the end of this article where you can download all code.</p>
<p><strong>Vertex Buffer Object</strong></p>
<p>All instances share the same mesh data, a vertex buffer and index buffer, while each of them has its own transform. For this example I store all this data in a single VBO with a memory layout as follows:<br />
<img class="aligncenter" src="https://lh4.googleusercontent.com/CBcyked9SN4rMC_lCf23CPWnIG1YUke0roxh25smfWVVfG-uxD0VwwWJjZDWCNSLSAUoeMit0Hlsw6b1ctPItnDx1Fm8NTiLldUIyZhorqvVEOEe_38" alt="" width="573px;" height="292px;" /><br />
The code to initialize this VBO is</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">glGenBuffers<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span>, <span style="color: #000040;">&amp;</span>cube_vbo<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
glBindBuffer<span style="color: #008000;">&#40;</span>GL_ARRAY_BUFFER, cube_vbo<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> dest<span style="color: #000080;">=</span>  <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span>glMapBuffer<span style="color: #008000;">&#40;</span> GL_ARRAY_BUFFER,GL_WRITE_ONLY<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">memcpy</span><span style="color: #008000;">&#40;</span>dest,cube_vertices,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>cube_vertices<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">float</span><span style="color: #000040;">*</span> positions <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span>dest<span style="color: #000040;">+</span><span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>cube_vertices<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">float</span><span style="color: #000040;">*</span> orientations <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span>dest<span style="color: #000040;">+</span><span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>cube_vertices<span style="color: #008000;">&#41;</span> <span style="color: #000040;">+</span> POSITION_BUFFER_SIZE<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//initialize the positions/orientations</span>
glUnmapBuffer<span style="color: #008000;">&#40;</span> GL_ARRAY_BUFFER<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p><strong>GLSL vertex shader</strong></p>
<p>For the GLSL vertex shader we need to apply the world transform, position and quaternion. As we use a single VBO and the positions and orientations are stored after the vertices, we need to specify the memory layout so the shader know where to find the position/orientation. For OpenGL this offset can be passed on using glVertexAttribPointer and layout. For OpenCL you can pass this offset as a kernel parameter.</p>
<p>There is a separate project in the solution called GLSL_instancing, to test this instancing. The implementation is in InitShaders();</p>
<p><strong>Initializing OpenCL</strong></p>
<p>Initializing OpenCL happens as usual, except for interop we need to pass the current OpenGL context:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">glCtx <span style="color: #000080;">=</span> wglGetCurrentContext<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
glDC <span style="color: #000080;">=</span> wglGetCurrentDC<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
cl_context_properties cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#123;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">0</span><span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> CL_CONTEXT_PLATFORM<span style="color: #008080;">;</span>
cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>cl_context_properties<span style="color: #008000;">&#41;</span>platform<span style="color: #008080;">;</span>
cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> CL_GL_CONTEXT_KHR<span style="color: #008080;">;</span>
cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>cl_context_properties<span style="color: #008000;">&#41;</span>pGLContext<span style="color: #008080;">;</span>
cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> CL_WGL_HDC_KHR<span style="color: #008080;">;</span>
cps<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>cl_context_properties<span style="color: #008000;">&#41;</span>pGLDC<span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> ciErrNum<span style="color: #008080;">;</span>
cl_context retContext <span style="color: #000080;">=</span> clCreateContextFromType<span style="color: #008000;">&#40;</span>cps, CL_DEVICE_TYPE_GPU,<span style="color: #0000ff;">NULL</span>,<span style="color: #0000ff;">NULL</span>,<span style="color: #000040;">&amp;</span>ciErrNum<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>There is a separate project called OpenCL_initialize to show the initialization. In the OpenCL_GL_interop project, the initialization happens in the InitCL method.</p>
<p><strong>Acquiring and releasing the buffer</strong></p>
<p>For each frame, before rendering all the instances, you can acquire the graphics buffer, run the OpenCL kernels and release the buffer with the following code snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">glFinish<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
cl_mem clBuffer <span style="color: #000080;">=</span> g_interopBuffer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getCLBUffer<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
cl_int ciErrNum <span style="color: #000080;">=</span> CL_SUCCESS<span style="color: #008080;">;</span>
ciErrNum <span style="color: #000080;">=</span> clEnqueueAcquireGLObjects<span style="color: #008000;">&#40;</span>g_cqCommandQue, <span style="color: #0000dd;">1</span>, <span style="color: #000040;">&amp;</span>clBuffer, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span>, <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
oclCHECKERROR<span style="color: #008000;">&#40;</span>ciErrNum, CL_SUCCESS<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> numObjects <span style="color: #000080;">=</span> NUM_OBJECTS<span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> offset <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>cube_vertices<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">4</span><span style="color: #008080;">;</span>
ciErrNum <span style="color: #000080;">=</span> clSetKernelArg<span style="color: #008000;">&#40;</span>g_interopKernel, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #008000;">&#41;</span>, <span style="color: #000040;">&amp;</span>offset<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
ciErrNum <span style="color: #000080;">=</span> clSetKernelArg<span style="color: #008000;">&#40;</span>g_interopKernel, <span style="color: #0000dd;">1</span>, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #008000;">&#41;</span>, <span style="color: #000040;">&amp;</span>numObjects<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
ciErrNum <span style="color: #000080;">=</span> clSetKernelArg<span style="color: #008000;">&#40;</span>g_interopKernel, <span style="color: #0000dd;">2</span>, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>cl_mem<span style="color: #008000;">&#41;</span>, <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">&amp;</span>clBuffer <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">size_t</span>	numWorkItems <span style="color: #000080;">=</span> workGroupSize<span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>NUM_OBJECTS <span style="color: #000040;">+</span> <span style="color: #008000;">&#40;</span>workGroupSize<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> workGroupSize<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
ciErrNum <span style="color: #000080;">=</span> clEnqueueNDRangeKernel<span style="color: #008000;">&#40;</span>g_cqCommandQue, g_interopKernel, <span style="color: #0000dd;">1</span>, <span style="color: #0000ff;">NULL</span>, <span style="color: #000040;">&amp;</span>numWorkItems, <span style="color: #000040;">&amp;</span>workGroupSize,<span style="color: #0000dd;">0</span> ,<span style="color: #0000dd;">0</span> ,<span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
oclCHECKERROR<span style="color: #008000;">&#40;</span>ciErrNum, CL_SUCCESS<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
ciErrNum <span style="color: #000080;">=</span> clEnqueueReleaseGLObjects<span style="color: #008000;">&#40;</span>g_cqCommandQue, <span style="color: #0000dd;">1</span>, <span style="color: #000040;">&amp;</span>clBuffer, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
oclCHECKERROR<span style="color: #008000;">&#40;</span>ciErrNum, CL_SUCCESS<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
clFinish<span style="color: #008000;">&#40;</span>g_cqCommandQue<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>Note that there is a more efficient way of synchonizing the buffers instead of using glFinish and clFinish using the <a href="http://www.opengl.org/registry/specs/ARB/cl_event.txt" target="_blank">ARB_cl_event</a> extension. I’ll implement and talk about that another time.</p>
<p><strong>The OpenCL Kernel</strong></p>
<p>The OpenCL kernel for this example is extremely simple, it just adds 0.01 to the y component of all positions:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">__kernel <span style="color: #0000ff;">void</span> interopKernel<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> startOffset, <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> numNodes, __global <span style="color: #0000ff;">float</span> <span style="color: #000040;">*</span>g_vertexBuffer<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> nodeID <span style="color: #000080;">=</span> get_global_id<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> nodeID <span style="color: #000080;">&lt;</span> numNodes <span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		g_vertexBuffer<span style="color: #008000;">&#91;</span>nodeID<span style="color: #000040;">*</span><span style="color: #0000dd;">4</span> <span style="color: #000040;">+</span> startOffset<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color:#800080;">0.01</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>This will be replaced by particle or simple rigid body dynamics with collision detection in an upcoming posting.</p>
<p>The screenshot at the beginning of the article is taken from the sample code: a OpenGL/glut demo that can render 125.000 instanced cubes in realtime, around 70 frames per second on my laptop with Radeon 6570M with GPU drivers supporting OpenCL 1.1. When increasing this to 1 million cubes it still runs at ‘interactive’ rates of a few frames per second. The demo also works on my NVIDIA GTX 260 desktop with OpenCL 1.0.</p>
<p><strong>Download</strong></p>
<p>You can download the full source code and precompiled executables from my <a href="https://github.com/erwincoumans/experiments" target="_blank">experiments repo at github</a>. The code is available under the permissive zlib license. To build it, click on buildvs2008.bat to generate Visual Studio 2008 project files using premake4 and then open the buildmsvc2008MySolution.sln. The glut demo is only tested on Windows 7 with Visual Studio. Feel free to contribute a port for your favorite OpenCL platform, such as Linux or Mac OSX.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/06/11/a-short-opencl-tutorial-updating-world-transforms-of-instanced-meshes-on-the-gpu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Contact generation between 3D convex meshes</title>
		<link>http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/</link>
		<comments>http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/#comments</comments>
		<pubDate>Fri, 13 May 2011 06:31:42 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
		
		<guid isPermaLink="false">http://altdevblogaday.org/?p=5737</guid>
		<description><![CDATA[<div><a href="http://altdevblogaday.com/wp-content/uploads/2011/05/convex_stacking.jpg"><img class="aligncenter size-medium wp-image-5740" src="http://altdevblogaday.com/wp-content/uploads/2011/05/convex_stacking-300x209.jpg" alt="" width="300" height="209" /></a></div>
<div>A large part of a rigid body dynamics engine is collision detection, in particular finding the contact points between objects. In games, non-moving world geometry is often represented by concave triangle meshes. Common collision shape representations for moving objects are basic convex shapes such as spheres, boxes and capsules and convex polyhedral meshes.</div>
<div>There are several efficient ways to generate contact points between convex polyhedral meshes, one method is based on Sutherland Hodgman clipping and another method builds multiple contact points by adding closest points to a persistent contact cache. I implemented both methods in the Bullet physics library, and you can download the source code from <a href="http://bullet.googlecode.com/">http://bullet.googlecode.com</a> in particular search for <a href="http://code.google.com/p/bullet/source/browse/trunk/src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp">btPolyhedralContactClipping</a>. There is also a basic sample in the <a href="https://github.com/erwincoumans/bullet3">Bullet3 github repository</a>, the screenshot above is taken from sample/api_bullet_physics/1_stable_convex.</div>
<div></div>
<p><a href="http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/" class="more-link">Read more on Contact generation between 3D convex meshes&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<div><a href="http://altdevblogaday.com/wp-content/uploads/2011/05/convex_stacking.jpg"><img class="aligncenter size-medium wp-image-5740" src="http://altdevblogaday.com/wp-content/uploads/2011/05/convex_stacking-300x209.jpg" alt="" width="300" height="209" /></a></div>
<div>A large part of a rigid body dynamics engine is collision detection, in particular finding the contact points between objects. In games, non-moving world geometry is often represented by concave triangle meshes. Common collision shape representations for moving objects are basic convex shapes such as spheres, boxes and capsules and convex polyhedral meshes.</div>
<div>There are several efficient ways to generate contact points between convex polyhedral meshes, one method is based on Sutherland Hodgman clipping and another method builds multiple contact points by adding closest points to a persistent contact cache. I implemented both methods in the Bullet physics library, and you can download the source code from <a href="http://bullet.googlecode.com/">http://bullet.googlecode.com</a> in particular search for <a href="http://code.google.com/p/bullet/source/browse/trunk/src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp">btPolyhedralContactClipping</a>. There is also a basic sample in the <a href="https://github.com/erwincoumans/bullet3">Bullet3 github repository</a>, the screenshot above is taken from sample/api_bullet_physics/1_stable_convex.</div>
<div>
<p>This blog posting I discuss the contact clipping method, and I’ll discuss the persistent contact caching method in a future posting.</p>
<h4>The basic recipe</h4>
<p>1) find the separating axis between the two convex polyhedra A and B<br />
2) search for a face in A and B that support the separating axis<br />
3) generate contact points by clipping one face from A against the convex hull B</p>
<h4>Finding the separating axis</h4>
<p>Given two convex polyhedra A and B, we need to find the axis with the minimum projected separation.  For step 1 in above recipe you can any method to find the separating axis. Two popular methods to find the separating axis are the separating axis test (SAT) and GJK named after its creators Gilbert, Johnson and Keerthi. Note that GJK needs a companion algorithm such as the expanding polytope algorithm (EPA) for the penetration case.</p>
<p>The SAT test is easier to explain and implement than GJK/EPA so here is a brief description. You can check the books by Gino van den Bergen and Christer Ericson for more details.</p>
<h4>SAT in a nutshell</h4>
<p>The potential separating axis can be either a face normal from A or B, or a cross product using edges from A and B, unless the edges are parallel. We can do an exhaustive search using all potential axis and computing the projection of the convex hull on those axis. We search for the axis with the largest separating distance. If maximum distance of the projection is positive, the object don’t overlap and we can terminate. In my implementation this step is implemented in btPolyhedralContactClipping::findSeparatingAxis.<br />
<img class="aligncenter" src="https://lh5.googleusercontent.com/1gEppkVZVSAci8zGzmHGbEvA7z8yG9bgZcaFMoFS1-0SHyckAvkj8Z-cRlftvuksRjx0P-dJnnCtDvhoX6JmQ0rZIEv9Bqd2NjipRhBhI-PP9fyrK-I" alt="" width="367px;" height="205px;" /></p>
<h4>Projection of the convex hull onto an axis</h4>
<p>The projection of a convex hull onto an axis can be computed by taking the vertex with the maximum dot product with the axis. Such search for a extreme vertex given a direction vector is also known as a support mapping.</p>
<h4>Reducing the number of separating axis tests</h4>
<p>The number of separating axis can grow fast and testing all axis can become a performance bottleneck.</p>
<p>1) Only use unique directions.<br />
For a box-box test this reduces the total number of candidates from 156 to 15 axis.<br />
2) First check against interior objects to cull detailed tests<br />
This was recently discussed by Pierre Terdiman in <a href="http://www.codercorner.com/blog/?p=461">this blog posting</a>: if the separating distance with a simplified object is already larger than the current smallest distance, then we don’t need to test the distance with the more complex convex hull. This optimization will easily reduce the total number of tests 90%.<br />
3) Once the minimal separating distance for a face goes beyond the current smallest distance, we can discard the remaining vertices for this face.</p>
<p>Even with above optimizations, I found that GJK/EPA test still outperforms the SAT test in many cases. I’m sure there are other optimizations possible, if you know any please leave a comment.</p>
<h4>Searching clipping faces</h4>
<p>Once we have the separating axis we can search for a face on A and a face on B with a normal that is closest to the separating axis. These are faces with maximum and minimum dot product of its face normal against the separating axis. In the picture those two faces are drawn in red:<img class="aligncenter" src="https://lh5.googleusercontent.com/1PA5IiGyXvR8zVSJtt8JpbpbXWSOgNcwYnde854VfYxxl0KcfCNUaRx2tD-l3dcivyu7p298LD6HgT-gJyYONPoB6ADdgU5yY5o7vnnHRTd10WdhdIo" alt="" width="298px;" height="222px;" /></p>
<h4>Sutherland–Hodgman clipping</h4>
<p>To generate multiple contact points, we can clip the face from one object against the hull of the other object. The wikipedia page has a good illustration about this clipping process:<br />
<img class="aligncenter" src="https://lh3.googleusercontent.com/LqfcV0KoW-kVVDncPCuFcPwR2rHQKK8y0rK1rTdwV0yyjYgoH8jgfo0bAVcxLoF7g2HQwxverco4qHPCqXoKmtdCqjvG0jgGFk4bADfZmpNBUz0QGsI" alt="" width="345px;" height="273px;" /><br />
Instead of clipping against the entire hull, we can only clip against the edge planes connected to the incident face in the other object. In the picture those edge planes are drawn in green:<img class="aligncenter" src="https://lh4.googleusercontent.com/jXUSyh4cxYLDoJboF7V0U90NRw6HsmS4YwxSsgHzmID49bx-5yd9_3-fYFatIC3ELiTqSMgLq1w-gxv5Ekht6_yKaZ6oMegjO5ZtdLngzjqMzl5b1XM" alt="" width="441px;" height="209px;" /></p>
<p>You can choose to perform this clipping in world space, or in the space of object A or B. The resulting contact points can be reported in world space or in one of the object spaces. You can check the implementation in btPolyhedralContactClipping::clipFaceAgainstHull.</p>
<h2>Contact reduction</h2>
<p>The contact generation method can produce a lot of contacts. We can reduce the number of contacts in several ways, for example only keep the following contact points:</p>
<p>1) the deepest point<br />
2) the furthest from the deepest point<br />
3) the furthest point from (2)<br />
4) the supporting point of a direction orthogonal to the edge connecting point (2) and (3)<br />
5) the support point of the negative orthogonal direction to this edge</p>
</div>
<p><span style="font-size: 20px;font-weight: bold">Convex decomposition</span></p>
<h2><span style="font-size: 13px;font-weight: normal">Convex polyhedral meshes can be created manually using authoring tools, or generated automatically from concave triangle meshes using convex decomposition methods. Khaled Mammou just released a brand new library for Hierarchical Approximate Convex Decomposition of 3D Meshes (HACD) that can be downloaded here <a href="https://sourceforge.net/projects/hacd/">https://sourceforge.net/projects/hacd</a></span></h2>
<p><span style="font-size: 13px;font-weight: normal"><a href="http://altdevblogaday.com/wp-content/uploads/2011/05/bunny.jpg"><img class="aligncenter size-medium wp-image-5744" src="http://altdevblogaday.com/wp-content/uploads/2011/05/bunny-300x170.jpg" alt="" width="300" height="170" /></a><br />
</span></p>
<p><span style="font-size: 13px;font-weight: normal">I plan to try out his convex decomposition method and discuss this in an upcoming blog posting.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sharing code</title>
		<link>http://www.altdevblogaday.com/2011/04/12/sharing-code/</link>
		<comments>http://www.altdevblogaday.com/2011/04/12/sharing-code/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 19:41:08 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
		
		<guid isPermaLink="false">http://altdevblogaday.org/?p=3859</guid>
		<description><![CDATA[<p>Making it easier to share efficient cross-platform code with others keeps me busy. I continue sharing a few thoughts about build systems, software licenses and code re-usability.</p>
<div>
<h2>Premake</h2>
<p><a href="http://altdevblogaday.com/2011/03/13/meta-build-systems/">Last time</a> I spoke about meta build systems, and following some suggestions I decided to finally give <a href="http://industriousone.com/premake">premake</a> a try.  I’m happy to report that it is doing a great job so far. Even though I had never used premake before, it only took an afternoon to have it auto generate Visual Studio, Mac OSX Xcode projects and Unix Makefiles the way I like it.</div>
<p><a href="http://www.altdevblogaday.com/2011/04/12/sharing-code/" class="more-link">Read more on Sharing code&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Making it easier to share efficient cross-platform code with others keeps me busy. I continue sharing a few thoughts about build systems, software licenses and code re-usability.</p>
<div>
<h2>Premake</h2>
<p><a href="http://altdevblogaday.com/2011/03/13/meta-build-systems/">Last time</a> I spoke about meta build systems, and following some suggestions I decided to finally give <a href="http://industriousone.com/premake">premake</a> a try.  I’m happy to report that it is doing a great job so far. Even though I had never used premake before, it only took an afternoon to have it auto generate Visual Studio, Mac OSX Xcode projects and Unix Makefiles the way I like it.</p>
<p>Premake takes away the suffering from cmake: its project files use relative paths so you can share its generated project files with others. Also it is easy to customize the various project configurations within one solution (32/64bit etc). You can see the result in a code base called Physics Effects that I recently open sourced together with Sony Computer Entertainment Japan. Just download a zipfile from <a href="https://github.com/erwincoumans/bullet3">https://github.com/erwincoumans/bullet3</a> and open the build directory, click on vc2008.bat and open build/vs2008/MySolution.sln</p>
<p>Physics Effects is a low level collision detection and rigid body dynamics library, optimized by Sony for the PlayStation 3 SPUs and for their new PSP2 ARM handheld. I’m using this Physics Effects code base as a start for Bullet 3, and optimize it for multi-threaded CPU, OpenCL and DirectCompute at AMD.</p>
<h2>Open source licenses</h2>
<p>In order to share code with game developers and film studios, you need to pick the right software license. I’ve been advocating the use of permissive software licenses such as <a href="http://www.opensource.org/licenses/bsd-license.php">BSD</a>, <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a>, <a href="http://www.opensource.org/licenses/apachepl.php">Apache </a>or <a href="http://www.opensource.org/licenses/zlib-license.php">zlib/libpng</a> for many years now, and fortunately many physics libraries are now available under permissive licenses, such as <a href="http://bulletphysics.org">Bullet</a>, <a href="http://box2d.org">Box2D</a>, <a href="http://www.ode.org">ODE</a>, <a href="http://www.opentissue.org">OpenTissue</a>, <a href="http://newtondynamics.com">Newton Dynamics</a>, <a href="http://xenocollide.snethen.com">Xenocollide</a>, <a href="http://www.rowlhouse.co.uk/jiglib">jiglib</a> etc.</p>
<p>In general it is best to avoid using code released under viral licenses such as LGPL and GPL in shipping games. Those licenses conflict with many non disclosure agreements (NDAs) and publishers won’t allow you to use those licenses. Just pick a permissive license if you want to share code with other game developers. If you are interested learning more about all aspects of open source, check out the book called &#8216;Producing Open Source&#8217;, there is a free download at <a href="http://producingoss.com/">http://producingoss.com</a></p>
<h2>Code re-usability</h2>
<p>In particular keeping your code free of external dependencies is an ongoing challenge.<br />
Vector math libraries, container classes and memory allocators easily cause conflicts.</p>
<p>Ideally you can share small independent code snippets that compile, link and run without further dependencies. For example John Ratcliff’s <a href="http://codesuppository.blogspot.com">code suppository</a> snippets and Sean Barrett’s minimalist and dependency<a href="http://nothings.org"> free coding style</a>, previously mentioned by Alex Evans.</p>
<p>Unfortunately when sharing collision detection and game physics snippets, it is often impractical to write code without at least a vector math library. At minimum it is convenient to have access to operators working on a float3/float4 vectors, unit quaternions and 3&#215;3 and perhaps 4&#215;4 matrices.</p>
<p>Switching to different underlying vector math library can be very labor intensive and error-prone, if you miss certain subtle details of those libraries. In some cases when merging several large software components, it can be better to leave each component using their own vector math libraries, rather than rewriting all using a common vector math library.</p>
<p>While merging Physics Effects with Bullet, I plan to replace Bullet&#8217;s current math library with Sony’s Vector Math library and let you know how things go.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/04/12/sharing-code/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Meta Build Systems</title>
		<link>http://www.altdevblogaday.com/2011/03/13/meta-build-systems/</link>
		<comments>http://www.altdevblogaday.com/2011/03/13/meta-build-systems/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 16:04:07 +0000</pubDate>
		<dc:creator>Erwin Coumans</dc:creator>
		
		<guid isPermaLink="false">http://altdevblogaday.org/?p=1911</guid>
		<description><![CDATA[<p>This is a story about my search for a hassle-free cross-platform open source (meta-/meta-meta-) build system.</p>
<p>For our open source <a href="http://bulletphysics.org/">Bullet</a> physics engine, I’ve been distributing the source code in a way that should make it as easy as possible to build out-of-the box. This means that for all supported platforms, the user (a developer who downloaded the Bullet SDK) should be able to download and unzip the zipfile or tarball on his machine, and get started as soon as possible. It should be hassle-free for the user but also for me, so I rather don’t manual updating too many files for each release.</p>
<p><a href="http://www.altdevblogaday.com/2011/03/13/meta-build-systems/" class="more-link">Read more on Meta Build Systems&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is a story about my search for a hassle-free cross-platform open source (meta-/meta-meta-) build system.</p>
<p>For our open source <a href="http://bulletphysics.org/">Bullet</a> physics engine, I’ve been distributing the source code in a way that should make it as easy as possible to build out-of-the box. This means that for all supported platforms, the user (a developer who downloaded the Bullet SDK) should be able to download and unzip the zipfile or tarball on his machine, and get started as soon as possible. It should be hassle-free for the user but also for me, so I rather don’t manual updating too many files for each release.</p>
<p>Aside from all the different platforms, we need to also support various compilers, compiler settings and integrated developer environments (IDEs). Common platforms are Windows, Mac OSX, iPhone, Linux as well as PlayStation 3 and XBox 360. Some common compilers are Visual Studio compiler, GCC, SN Systems and LLVM.</p>
<p>Here are a couple of build systems and modifications that I tried or considered to try:</p>
<p>Visual Studio project files. Shipping manual generated visual studio files works hassle-free for the user, but isn’t hassle-free for myself especially if you want to support all versions from MSVC 6 up to MSVC 2010. Obviously it is also not cross-platform so it needs to be combined with another build system. For example autotools.</p>
<p>autotools: for most unix flavors, autotools does a great job. It is often already installed and is fairly hassle-free, as long as the user doesn’t run into version compatibilities of automake, autoconf or libtool. It is a bit of a hassle for me, because I’m not too familiar with autotools and can only provide most basic support. A bigger issue is that autotools doesn’t support IDEs such as Xcode.</p>
<p>Xcode, the environment for Mac OSX and iPhone, requires its own project files. Shipping manual generated project files is a burden, when dealing with versions and platform settings.</p>
<p>jam and msvcgen: jam is a fast build system and it is small enough to ship the entire jam source code together with my own project (it is just a few hundred kilobytes with no external dependencies). The msvcgen extension could autogenerate standalone Visual Studio project files from MSVC 6 onwards, so that was a nice extra. For several years I’ve been shipping the Bullet SDK with autotools + jam and msvcgen autogenerated Visual Studio projects for MSVC 6, 7 and 2005. No proper support for XCode, until I noticed cmake.</p>
<p><a href="http://cmake.org/">cmake</a>: this is almost a dream meta build system but unfortunately it cannot properly generate distributable build systems. For example the generated Visual Studio project files only work on the local machine. I’ve been hacking the cmake source code so that it does generate distributable project files, and submitted a few patches back to cmake. Unfortunately, the main cmake developers don’t want to support distributable project file generation, and I felt they were very reluctant to discuss further changes to support distributable project files. For example, I need the option to avoid creating copy rules that depend on cmake being installed. Furthermore any environment variables should not be expanded in absolute paths but stay environment variables for shipping project files (for example DXSDK_DIR, ATISTREAMSDKROOT or NVSDKCOMPUTE_ROOT for some recent OpenCL and DirectCompute accelerated optional modules). This means that I need to keep on using and updating a forked version of cmake to generate and distribute MSVC projectfiles. As a side note: the wxWidgets project even created their own build system, just because of this cmake shortcoming. Another shortcoming of cmake is lack of multiple compiler support, so generating projects for both PlayStation PPU and SPU is not possible. After bringing up my build system issue on the PS3 Devnet forums, someone mentioned premake.</p>
<p><a href="http://industriousone.com/premake">premake</a> is a very promising meta build system and I keep on thinking of trying it out. I’ve heard people who create PS3 and XBox 360 project files, and it supports most other platforms. Premake can be optionally extended using Lua, but it is not a requirement for Lua to be installed, unlike the Python requirement for scons. Unfortunately, I’ve heard that premake has some issues with dependency tracking, has less features that cmake and it is not widely supported yet. This means that integrating it into another project might become a hassle.</p>
<p>This leaves me to either wait until premake matures and becomes more widely used, or writing my own meta-meta build system that can generate both cmake, premake and other project files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.altdevblogaday.com/2011/03/13/meta-build-systems/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.810 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-17 03:58:31 -->
<!-- Compression = gzip -->
