<?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>Game Haxe &#187; hxcpp</title>
	<atom:link href="http://gamehaxe.com/category/hxcpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamehaxe.com</link>
	<description>Experimenting with Web Game Development</description>
	<lastBuildDate>Tue, 24 Apr 2012 15:57:38 +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>WWX Conference</title>
		<link>http://gamehaxe.com/2012/04/24/wwx-conference/</link>
		<comments>http://gamehaxe.com/2012/04/24/wwx-conference/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 15:57:38 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[wwx]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=419</guid>
		<description><![CDATA[I recently got back from &#8216;WWX&#8217;, the World Wide Haxe conference. I had a fantastic time &#8211; got to meet a whole bunch of people from the community. I gave a presentation about the architecture and some details of the &#8230; <a href="http://gamehaxe.com/2012/04/24/wwx-conference/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently got back from &#8216;WWX&#8217;, the World Wide Haxe conference.  I had a fantastic time &#8211; got to meet a whole bunch of people from the community.</p>
<p>I gave a presentation about the architecture and some details of the hxcpp backend.  The slide are in <a href='http://gamehaxe.com/wp-content/uploads/2012/04/wwx2012-hxcpp.pdf'>wwx2012-hxcpp.pdf</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2012/04/24/wwx-conference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NME From Scratch</title>
		<link>http://gamehaxe.com/2011/04/05/nme-from-scratch/</link>
		<comments>http://gamehaxe.com/2011/04/05/nme-from-scratch/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 16:37:26 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[neko]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[Haxe]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=386</guid>
		<description><![CDATA[Part 1 &#8211; Get The Basics Going I&#8217;ve just got a shiny new computer at home &#8211; nothing installed. So it seems like a good chance to go through exactly what it takes to get and NME sample up and &#8230; <a href="http://gamehaxe.com/2011/04/05/nme-from-scratch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Part 1 &#8211; Get The Basics Going</h1>
<p>I&#8217;ve just got a shiny new computer at home &#8211; nothing installed.  So it seems like a good chance to go through exactly what it takes to get and NME sample up and running on a new Windows 7 box.</p>
<p><em>8:20pm</em> For starters, I&#8217;ll need a c++ compiler, so first thing is to start the MSVC 2010 Express downloading: <a href="http://www.microsoft.com/express/Downloads/#2010-Visual-CPP">2010-Visual-CPP</a>.</p>
<p><em>8:25pm</em> OK &#8211; I&#8217;ve signed my rights away and that is downloading.  The next thing I&#8217;ll need is haxe.  It is easy to install from <a href="http://haxe.org/download">here</a>.</p>
<p><em>8:28pm</em> Haxe 2.07, neko 1.81 downloaded and installed.  Windows complained that it might not have installed correctly, but this is just because the exe had &#8220;installer&#8221; in the name, and did not write an &#8220;uninstall&#8221; entry.</p>
<p>Test: Start a &#8220;<strong>cmd</strong>&#8221; prompt by clicking on the Windows start circle and type &#8220;<strong>cmd</strong>[Enter]&#8221; into the search box.  And in this box, type &#8220;<strong>haxe</strong> [Enter]&#8220;. I am now rewarded with the haxe help message.</p>
<p><em>8:35pm</em> Visual C++ Express in successfully installed.<br />
Test:  Start up a new cmd shell, and type &#8220;<strong>cl</strong>&#8220;.  This does not work because the exe can&#8217;t be found in my path.  But here is the trick.  Type <strong>&#8220;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat&#8221;</strong> at the prompt (note:include the quotes!), and get the message &#8220;Setting environment for using Microsoft Visual Studio 2010 x86 tools.&#8221;.  Now &#8220;<strong>cl</strong>&#8221; is rewarded with the Microsoft banner.</p>
<p><em>8:41pm</em>  I&#8217;m on a bit of a roll here, so I&#8217;ll see if I can get an haxe project going.  As I said, I have nothing installed, so I&#8217;ll go old-school.  First thing is to make a directory.  The cmd prompt starts in my home directory (c:\Users\Hugh), and I will make a directory:<br />
<strong>mkdir projects<br />
cd projects<br />
mkdir hello<br />
cd hello</strong><br />
And now, do the best I can:<br />
<strong>notepad.exe Hello.hx</strong>  (yes I do want to create the file)<br />
<code>
<pre>
class Hello
{
  public static function main()
  {
     trace("Hello!");
  }
}
</pre>
<p></code><br />
And switch back to the cmd prompt:<br />
<strong>haxe -main Hello -neko hello.n<br />
neko hello.n</strong><br />
Hello.hx:5: Hello!</p>
<p>Woo Hoo! <em>8:48pm</em> and I&#8217;ve run my own program.</p>
<p>Now lets get even more adventurous, and try a c++ example.  Trying:<br />
<strong>haxe -main Hello -cpp bin</strong><br />
Tells me that &#8220;Project hxcpp is not installed&#8221; &#8211; so let&#8217;s install it:<br />
<strong>haxelib install hxcpp</strong><br />
And try again:<br />
<strong>haxe -main Hello -cpp bin</strong><br />
And test:<br />
<strong>bin\Hello.exe</strong><br />
<em>8:43pm</em>, I have my first hxcpp prgram working!</p>
<p>Now, try for some graphics:<br />
<strong>haxelib intall nme</strong><br />
and start a new project:<br />
<strong>cd ..<br />
mkdir graphics1<br />
cd graphics1<br />
copy &#8220;c:\Motion-Twin\haxe\lib\nme\2,0,1\samples\02-Text\Sample.hx&#8221;<br />
haxe -main Sample -cpp bin -lib nme<br />
bin\Sample.exe</strong></p>
<p><em>9:05pm</em> And there it is. Haxe, neko, hxcpp, nme VC2010 installed and run in 40 minutes, including this write up.</p>
<h1>Part 2 &#8211; Compile NME From Source</h2>
<p>Well, that went much better than I expected, so I will now attempt some bleeding-edge stuff.  The version on NME used above is old, and I have no one to blame but myself.  My intentions are to do a release soon, but I just have not got my finger out.  Which leave me with the option of compiling NME from source if I want the latest features.</p>
<p>First thing, is to create a place where I can download various bits of source code for compiling.  I&#8217;m going to put it a &#8220;e:\code.google&#8221;, because my C drive is a fast SSD, and has limited room.</p>
<p><strong>e:<br />
mkdir code.google<br />
cd code.google</strong></p>
<p>Following the instructions from the <a href="http://code.google.com/p/nekonme/source/checkout">source page</a>, but changing the name, I can get a copy with:<br />
<strong>svn checkout http://nekonme.googlecode.com/svn/trunk/ nme</strong><br />
- if only I had svn installed. So first install this, I&#8217;ll be using <a href="http://sourceforge.net/projects/win32svn/">this version</a>. Once installed, I have to restart the cmd prompt and do the vsvars32.bat thing again.  Now when I try again, I get the required files.  There is also a companion project to go with NME, and that is the &#8220;sdl-static&#8221; project, which contains libraries required by NME.  To get this, simply do:<br />
<strong>svn checkout http://sdl-static.googlecode.com/svn/trunk/ sdl-static</strong><br />
This takes a while&#8230;.</p>
<p>Time to build -<br />
<strong>cd nme\project<br />
haxelib run hxcpp Build.xml</strong><br />
The &#8220;haxelib&#8221; tool looks for a file called &#8220;run.n&#8221; in an installed haxe library and runs it.  In the hxcpp project, the run.n file gathers compiler options to build the haxe output. This same program can be used to build other projects &#8211; including the NME project.  Unfortunately, compiling NME like this gives the error &#8221; cannot open input file &#8216;ddraw.lib&#8217;&#8221;.  This is because the VC express install does not have all the required system support files.  This file can be found in the &#8220;DirectX SDK&#8221;, and I&#8217;ll be using the <a href="http://msdn.microsoft.com/en-us/directx/aa937788">June 2010 version</a>.  This is a huge file, so it will take a while.  If you think it is a lot of effort for a tiny lib, then you are right.</p>
<p><em>10:10pm</em> and the download has finished.  I have chosen to install it in &#8220;e:\SDKs\Microsoft DirectX SDK (June 2010)&#8221;, because I&#8217;m trying not to put crap on my C drive, and I will be installing quite a few SDKs, and it is nice to have them all together.</p>
<p>This does not immediately fix the problem, because the NME project does not know where I installed it.  This is where the per-machine hxcpp config comes in.</p>
<p>Following the instructions in BuildCommon.xml, I create a file in &#8220;C:\Users\Hugh&#8221; called &#8220;.hxcpp_config.xml&#8221;, and put the following in it:</p>
<p><code></p>
<pre>
&lt;xml>
  &lt;section id="exes">
     &lt;linker id="dll" if="windows">
        &lt;flag value = "-libpath:e:\SDKs\Microsoft DirectX SDK (June 2010)\Lib\x86"/>
     &lt;/linker>
  &lt;/section>
&lt;/xml>
</pre>
<p></code></p>
<p>Oh crikey! Looks like Microsoft in their wisdom have dropped support for this ddraw.lib, and I&#8217;m currently using a version of SDL that needs it! It&#8217;s OK, problem solved &#8211; I&#8217;ve added it to the NME project, but you still need the SDK for dxguid.lib, which I guess I should also add.</p>
<p>Anyhow, after a long delay, at <em>10:30pm</em> I have NME building!</p>
<p>Now, going back to the original graphics1 example, the first thing to do is tell haxe to use our SVN haxe code instead of the 2.0.1 dowloaded from haxelib.  This is done via:<br />
<strong>haxelib dev nme e:/code.google/nme</strong></p>
<p>Then build &#038; test:<br />
<strong>haxe -main Sample -cpp bin -lib nme<br />
bin\Sample.exe</strong></p>
<p>Which works as before.  But now we can test some of the new features in NME.  First get the new sample, and the new associated project file:<br />
<strong>copy e:\code.google\nme\samples\02-Text\Sample.hx .<br />
copy e:\code.google\nme\samples\02-Text\Sample.nmml .</strong></p>
<p>Then you can use the NME build tool, with the command &#8220;test&#8221; (which is &#8220;build&#8221; and &#8220;run&#8221;) on the Sample.nmml project file, and for the target &#8220;neko&#8221;.<br />
<strong>haxelib run nme test Sample.nmml neko</strong><br />
And you can see the result.  Then you can test for cpp:<br />
<strong>haxelib run nme test Sample.nmml cpp</strong></p>
<p>So it&#8217;s now <em>10:45pm</em> (had to catch the end of &#8220;Dexter&#8221;) and I&#8217;ve successfully compiled the latest version of NME and tested the new project feature.</p>
<h2>Part 3 &#8211; Android</h2>
<p>Things seem to still be going well, so I&#8217;m going to take one more step &#8211; android (spoiler &#8211; this is going to take longer than expected).  First thing to so is install the <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java Development Kit</a>. (NOTE: Install the &#8220;windows&#8221; version, not the &#8220;x64&#8243; version) Then, the <a href="http://developer.android.com/sdk/index.html">android SDK</a>.<br />
I installed java JRE and JDK in my SDK directory, but Google&#8217;s (always painful) build tools seem to think I have not installed java, even though it works from the cmd prompt.  Thank guys. So I&#8217;ve uninstalled it, and reinstalled the JRE in the default location, and now it seems happy.  The Android SDK download is just the start &#8211; it now runs and downloads a whole bunch more.  This looks like it may take some time&#8230;</p>
<p>I may as well get on with <a href="http://developer.android.com/sdk/ndk/index.html">downloading the NDK</a> too.   And while I wait for those I&#8217;ll get my phone ADB USB drivers installed.  My HTC phone actually installs the drivers when I install HTCSync, found on my sdcard that was shipped with it.<br />
<em><strong>EDIT</strong>: The android ndk r5b still has issues with exceptions/c++.  However, these can be solved by dropping <a href="http://gamehaxe.com/wp-content/android/libstdc++.a">this version of libstdc++.a</a> from the Crystax r4 distribution over the top of sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a in your downloaded ndk.  If google ever manage to write a good build system, they might end up being a successful company.</em></p>
<p>The Google build tools also require <a href="http://www.cygwin.com/install.html">the &#8220;Cygwin&#8221; utilities</a>, so install these too.</p>
<p>Finally, we will need a new version of hxcpp, which we can get with:<br />
<strong>e:<br />
svn checkout http://hxcpp.googlecode.com/svn/trunk/ hxcpp<br />
haxelib dev hxcpp e:\code.google\hxcpp</strong></p>
<p><em>11:45pm</em>, I have finally downloaded and installed the Android prerequisites (I think) but will give up now.</p>
<p><em>Next day</em> &#8211; Here we go again.  Now to use the google android NDK, you need to have the cygwin dlls in your exe path.  To change the path, right click in the &#8220;Computer&#8221; shortcut in the start menu, and choose &#8220;properties&#8221;, then on the left &#8220;Advance system settings&#8221;, then the &#8220;Environment Variables&#8221; button and scroll through the top bit for &#8220;PATH&#8221; and click &#8220;edit&#8221;.  This already has haxe and neko in it, so we add the cygwin:<br />
<strong>%HAXEPATH%;%NEKO_INSTPATH%;e:\SDKs\cygwin\bin</strong><br />
Now restart the cmd prompt, and typing &#8220;<strong>ls</strong>&#8221; should work.<br />
And one more thing &#8211; in lieu of using &#8220;eclipse&#8221; for java building (which I just can&#8217;t stand &#8211; don&#8217;t get me started), the google tools need the <a href="http://ant.apache.org/bindownload.cgi">&#8220;ant&#8221; program</a>, which you install by unzipping somewhere.</p>
<p>Tell the build system where we installed these things.</p>
<p><strong>set ANT_HOME=e:/SDKs/ant<br />
set ANDROID_SDK=e:\SDKs\android-sdk<br />
set ANDROID_NDK_ROOT=e:\SDKs\android-ndk<br />
set JAVA_HOME=e:\SDKs\Java\jdk1.6.0_24</strong></p>
<p>And rebuild nme, like before, except that the &#8220;obj&#8221; directory should be removed first, because I have not yet allowed 2 compilers to be running at the same time.<br />
<strong>haxelib run hxcpp Build.xml -Dandroid</strong></p>
<p>Now, back in the original directory, we can build + run for android:<br />
<strong>haxelib run nme test Sample.nmml android</strong></p>
<p>Which, finally, works! You can terminate the debug log with control-c.</p>
<p>So, an awful lot of set up, but subsequent projects should only be a single line.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2011/04/05/nme-from-scratch/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Android + HXCPP &#8211; a Quickstart Guide</title>
		<link>http://gamehaxe.com/2010/09/30/android-hxcpp-a-quickstart-guide/</link>
		<comments>http://gamehaxe.com/2010/09/30/android-hxcpp-a-quickstart-guide/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 06:18:55 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Haxe]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=341</guid>
		<description><![CDATA[After having some success with making an Xcode template, I thought it would be relatively easy make something similar for eclipse and Android. However, there was nothing but pain for me when I tried, so instead I&#8217;ve decided to write &#8230; <a href="http://gamehaxe.com/2010/09/30/android-hxcpp-a-quickstart-guide/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After having some success with making an Xcode template, I thought it would be relatively easy make something similar for eclipse and Android.  However, there was nothing but pain for me when I tried, so instead I&#8217;ve decided to write this guide.</p>
<h3>Prerequisites</h3>
<p>There are quite a few prerequisites you need to organize before you can get things going.  Android allows building from Windows, Mac and Linux.  The procedures are quite similar, except that Windows requires some messing about with Cygwin binaries.  The method described here avoids most of the Cygwin pain \- and the google make sytem pain \- by avoiding the google make sysem altogether.</p>
<ul>
<li>Download and install the <a href="http://developer.android.com/sdk/index.html">Android SDK</a>.  This is the Java tools and libraries required for building and debugging byte-code applications.
<li>
<li> Download and install eclipse IDE.  This is the IDE that runs the SDK &#8211; follow the instructions on the Android SDK page and install the Android plugins too.</li>
<li> Install the USB drivers for your device (if required).  For my device (HTC Legend) I found the drivers on the phone itself by using it as a thumb drive.
</ul>
<p>You should now be in a position to build some sample (byte-code) applications for your device.</p>
<ul>
<li>Download the Android Native Development Kit.  This allows you to build binary code for your device.  Now for HXCPP, it is <b>very important</b> to download the latest build provided at <a href="http://www.crystax.net/android/ndk.php">Crystax.net</a>, which is a build done by a generous community member that corrects some of the glaring omissions of the official build, namely RTTI and exceptions.  If it is all the same to you, extract it to c:/tools/android-ndk for Windows, and ~/tools/android-ndk for other systems, and this will make the remaining instructions easier.
</li>
<li> Currenly on Windows, you need the svn version of HXCPP (slightly newer that 2.06.1) which has some include path fixes.  See the instructions at <a href="http://code.google.com/p/hxcpp/">http://code.google.com/p/hxcpp/</a> for getting the latest version.</li>
<li> Also on windows, you need the Cygwin dlls in your path.  One way to do this is to install the whole Cygwin toolchain and put it in your path.  The other way so to drop the two dlls from <a href="/wp-content/android/cygwin-extra.tgz">cygwin-extra.tgz</a> into the ndk binary directory, ie c:/tools/android-ndk/build/prebuilt/windows/arm-eabi-4.4.0/bin.</li>
</ul>
<h3>Project structure</h3>
<p> An android project consists several  components that all work together.</p>
<ul>
<li> Java Code.  The Java code provided in the sample project comes from a couple of places.  Because the project is graphics based, the copy NME Java code is included.  If the version of NME increases, it may be desirable to update the NME code, either by copying the new code in, or instead linking to the NME code directly.  Also, the HXCPP bootstrap Java code is included along with a small Activity wrapper file.</li>
<li> Native code.  The shared object files provide native code for running on the device.  These include the standard libraries, the NME library and the haxe code compiled with hxcpp.</li>
<li>AndroidManifest.xml. This controls how your application is deployed, and quite a few things can be done with this file.  It is best to consult the Android documentation about what can be done here.
<li>Resources &#038; Assets.  These can be useful if you want to add standard menus or other GUI elements to your application.
</ul>
<p>The basic workflow starts by making a change to your haxe source files.  You then compile the haxe code to Android cpp, which is in turn is compiled to an android shared object.  This .so file is then copied to the libs/armeabi directory in the project.  Because eclipse does not recognize a change to the shared objects as a important update, it is then necessary to touch one of the Java files so that eclipse rebuilds the project.  These steps are handled by the build_haxe batch/shell scripts provided with the project, so all you should have to do is change the code and run the script.  Then, press the &#8220;play&#8221; button in eclipse(the first time you do this, you may need to specify Run-As Android Project) and your application should launch.</p>
<p>The haxe code included in the sample directory uses a fixed class name, AndroidMain, as the bootstrap point for building the haxe shared object, libAndroidMain.so.  By fixing these names, the build script is simplified. I encourage you to put your main code for the application outside the provided project directory, and edit the AndroidMain.hx and build.hxml files to point to this external application code.  This will help with cross-platform development, and keep the boiler-plate code separate from your precious source code.</p>
<h3>Creating a New Project</h3>
<p>I could not find a very nice way to make a project template, so this is what I&#8217;ve come up with.  First, download and extract the example project, <a href="/wp-content/android/android-2.06.1.tgz">android-2.06.1.tgz</a>.  You may like to rename the parent directory from android-2.06 to something more meaningful at this stage.</p>
<p>At this point, you should be able to build the sample haxe code using the build-scripts provided.  This requires your prerequisite installations to be good, so it is worth testing.  If you have downloaded the android-ndk to a different location, you can edit the appropriate build script to reflect this.  You will need the latest NME code from haxelib.  Windows users may also need the svn version of HXCPP.</p>
<p>So that all worked?  Congratulations, your system is set up for development.</p>
<p>Next, fire up eclipse, and create a &#8220;File &#8211; New Project..&#8221;, then select &#8220;Android Project&#8221;, then select  &#8220;Create project from existing source&#8221;, and browse to your newly created directory.  You will notice that down the bottom of the Dialog, the properties are filled out with names from the sample project &#8211; we will change these next.  Once you select &#8220;Finish&#8221;, your project should be created, and ready to run on your device.</p>
<p>The project and package names are tied into Java and Android naming conventions, as well as the Android manifest, and can be difficult to budge.  It is easiest to use the eclipse Refactor-Rename menu option to change the name from &#8220;MyActivity&#8221; to something more appropriate for you, say &#8220;CircleDisplay&#8221;.  Then in the source tree under &#8220;src&#8221;, there is a file in com.company called &#8220;MyActivity.Java&#8221;.  Select this, and use the menu option to change its name to &#8220;CircleDisplay&#8221; too.  Similarly, select the &#8220;com.company&#8221; and change this to something else, in my case &#8220;com.gamehaxe&#8221; (select preview and agree to everything).  There is one final change required &#8211; the refactor option misses a reference in the AndroidManifest.xml because it starts with a period.  Double click this and in the &#8220;AndroidManifest.xml&#8221; tab, change the &#8220;.MyActivity&#8221; to &#8220;.CircleDisplay&#8221;.</p>
<p>It is important to rename these items because it effects how your application is ultimately stored in the device.</p>
<p>So now you should be good to go &#8211; press the play button and select &#8220;Android Project&#8221;.</p>
<p>There are quite a few things that can go wrong with so many things to install, so I&#8217;ve got my fingers crossed for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/09/30/android-hxcpp-a-quickstart-guide/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Minor Updates</title>
		<link>http://gamehaxe.com/2010/09/12/minor-updates/</link>
		<comments>http://gamehaxe.com/2010/09/12/minor-updates/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 16:14:25 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[nme]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=336</guid>
		<description><![CDATA[I have just released a few minor updates to nme + hxcpp, which you can find on haxelib. These are relatively small \- just pushing out a few fixes for some bugs that have been reported. In most cases the &#8230; <a href="http://gamehaxe.com/2010/09/12/minor-updates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have just released a few minor updates to nme + hxcpp, which you can find on haxelib.  These are relatively small \- just pushing out a few fixes for some bugs that have been reported.  In most cases the bug reports we accompanied by a fix \- you&#8217;ve gotta love open source.  The <a href="http://gamehaxe.com/wp-content/xcode/NMETemplate-2.0.1.tgz">iPhone/Xcode template has also been updated</a>, you may need to follow the instructions in the post below.</p>
<p>There is one significant change though &#8211; the &#8220;nekoapi.dll&#8221; file that is used for compatibility between hxcpp binaries (ie, NME) and neko has changed its extension to &#8220;ndll&#8221; so that neko can communicate directly with it.  This allows the String instances created externally to be &#8220;blessed&#8221; as haxe strings without having to call nekoToHaxe on them, and therefore methods such as substr will work.</p>
<p>The other change of note is that I removed the libfreetype code from the iPhone target, and used native font rendering instead.  Let me know if this breaks anything.  One side effect is that the default font will now be system dependent, with the iPhone getting its usual font.  I will also have to have a good look at the font render quality &#8211; freetype may have a little bit better sub-pixel sharpness.</p>
<p>There was a bug in the 2.06 haxe distribution when writing files.  I have fixed this by putting an override in hxcpp, which you can access with the command line options: &#8220;-lib hxcpp&#8221;.  I have also folded this change into haxe svn, so you will not need to do this in 2.07.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/09/12/minor-updates/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>New Releases!</title>
		<link>http://gamehaxe.com/2010/08/19/new-release/</link>
		<comments>http://gamehaxe.com/2010/08/19/new-release/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 15:27:28 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[neash]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=326</guid>
		<description><![CDATA[Finally, I&#8217;ve managed to make a few more releases. Namely, HXCPP 2.06 and NME 2.0. HXCPP can be downloaded via &#8220;haxelib&#8221;, and works with the new 2.06 version of haxe. This release contains many bug fixes and optimizations. Also, when &#8230; <a href="http://gamehaxe.com/2010/08/19/new-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Finally, I&#8217;ve managed to make a few more releases.  Namely, HXCPP 2.06 and NME 2.0.<br />
HXCPP can be downloaded via &#8220;haxelib&#8221;, and works with the new 2.06 version of haxe.  This release contains many bug fixes and optimizations.  Also, when you compile with the -debug flag, you can get additional null checks and stack dumps.<br />
NME 2 is a complete rewrite from the ground up.  Most of the logic has been moved from neash to the c++ code for optimization reasons.<br />
For NME developers this only means a couple of things:</p>
<ul>
<li> You use &#8211;remap flash=nme instead of &#8211;remap flash=neash</li>
<li> The &#8220;boot&#8221; code has changed, so you will need to follow the main line from one of the samples. </li>
<li> Improved performance! </li>
</ul>
<p>I updated my Xcode SDK, which caused a bunch of link errors linking for the simulator with the NME library.  It seems Apple have changed the &#8220;ABI&#8221; for objc (basically, broke binary compatibility).  So I must choose pre 4.0, post 4.0 or both.  I think I am going to require NME iphone simulator users to have the latest SDK &#8211; unless there are any objections?</p>
<h2>iPhone Xcode Template</h2>
<p>I finally got around to making an Xcode template for haxe compiling. <a href="http://gamehaxe.com/wp-content/xcode/NMETemplate-2.0.0.tgz">Try it out</a> and let me know if it works.  It&#8217;s my first one, so I&#8217;m open to ideas for improving it.</p>
<p>To use the template, first extract it to your developer template area, eg: /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application.<br />
Then when you create an new Xcode project, this template should show up.  You should be able to build for the simulator.</p>
<p>To build for a real device, you will need to go though the official Apple developer program, and get yourself signed up.  Then you need to get your certificates in order, and finally edit the &#8220;plist&#8221; file in the Resources folder and change the company URL to match the one you used in your certificates.</p>
<p>You can edit Main.hx code in the &#8220;haxe/src&#8221; directory, but you will probably want to locate your haxe source tree outside your project area, since we are multi-platform developers an do not  want to tie ourselves to Xcode.  To do this, you can edit the class path in the Build.xml file, and change the boot code in IPhoneMain.hx.  It is done this way so the haxe-generated library always has the same name.  If all else fails, you can have a look in the makefile, which is set up to allow building debug and release versions for iphoneos and simulator without having to change other project settings.</p>
<p>Let me know if you have any luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/08/19/new-release/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Android Port &#8211; Second Look</title>
		<link>http://gamehaxe.com/2010/06/29/android-port-second-look/</link>
		<comments>http://gamehaxe.com/2010/06/29/android-port-second-look/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 15:54:58 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[Result]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[ndk]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=321</guid>
		<description><![CDATA[I have looked into some of the performance aspects of the Android port, and I&#8217;ve come to some conclusions. Firstly, after looking at the disassembly, there did not seem to be any additional code associated with exception handling, so there &#8230; <a href="http://gamehaxe.com/2010/06/29/android-port-second-look/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have looked into some of the performance aspects of the Android port, and I&#8217;ve come to some conclusions.  Firstly, after looking at the disassembly, there did not seem to be any additional code associated with exception handling, so there was no optimizing to be done there.  Secondly, the compile flags meant that software floating point operations were used, rather than the built-in hardware FPU.</p>
<p>So I added compile flags to force hardware floats, and added armv6 instructions while I was at it.  <a href="http://gamehaxe.com/wp-content/android/hxAndroid-fpu.apk">You can get the installer here</a>.</p>
<p>This gives my phone a nice 50% boost in frame-rate to about 15fps.  However, on some devices this app may fail to run.  This change brings the performance in line with iPhone performance for the simulation side of the program.  However the OpenGL seemed slower.  I guess the Qualcomm MSM 7227 does not have strong 3D acceleration \- or perhaps I am still missing something?</p>
<p>For comparison, you can test the flash version of the code <a href="http://gamehaxe.com/wp-content/android/">in this directory</a>.  I get about 6\-7 fps, which is not too far from my initial software-float based results and is quite impressive.  I&#8217;m not sure if the flash renderer is using software or hardware rendering \- maybe it&#8217;s worth a closer look to find out what it&#8217;s doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/06/29/android-port-second-look/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Android Port &#8211; First Light</title>
		<link>http://gamehaxe.com/2010/06/28/android-port-first-light/</link>
		<comments>http://gamehaxe.com/2010/06/28/android-port-first-light/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 14:23:27 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[ndk]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=309</guid>
		<description><![CDATA[I bought myself and Android (2.1) HTC Legend phone. Obviously, the first thing I wanted to do was to get haxe/NME running on it. Now the Android platform is very well setup for Java development but, unfortunately, the haxe Java &#8230; <a href="http://gamehaxe.com/2010/06/28/android-port-first-light/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I bought myself and Android (2.1) HTC Legend phone.  Obviously, the first thing I wanted to do was to get haxe/NME running on it.   Now the Android platform is very well setup for Java development but, unfortunately, the haxe Java target is not fully developed at the moment.  Luckily, there is also a &#8220;native&#8221; development kit (NDK) that allows you to run c++ code on the device using a Java bootstrap to load the code and JNI.</p>
<p>The NDK is based in the GCC toolchain, and therefore is already pretty well supported by the hxcpp haxe backend.  The problem is that the standard NDK is somewhat crippled &#8211; it does not support exceptions or the STL.  It is possible to rework the hxcpp backend to work without the STL, but removing exceptions may take a bit more work.   I managed to work around this by using a slightly modified NDK, created by a very helpful member of the comminity over at <a href="http://www.crystax.net/android/ndk-r4.php">crystax.net</a>.  In theory this should have been all that was required, however the NDK also lacks proper wchar_t support.  When I finally worked this out, it was reasonably easy to substitute a simple translation layer to fix these wide-char problems.<br />
<a href="http://gamehaxe.com/wp-content/uploads/2010/06/Android1.png"><img src="http://gamehaxe.com/wp-content/uploads/2010/06/Android1.png" alt="" title="Android1" width="480" height="320" class="alignleft size-full wp-image-312" /></a>  So far, I have only implemented the rendering API, with no interactive options.  The OpenGL ES rendering code is exactly the same as for the iPhone, except that the initial context and display surface are setup in the Java code, rather than the Objective C code.</p>
<p>Developing with haxe for the Android target requires several modules to work together.  First, you compile your haxe code as normal to a shared object &#8211; which is actually a JNI module.  This exposes a single &#8220;main&#8221; function that can be called from Java.   Your actual Android application starts with Java code, and you can setup the properties etc. from eclipse.  Ultimately this will be boilerplate code and you will only need to change the bits you need to.  This Java code then calls the haxe main function.  In the graphical/NME environment the main thing this does is dynamically load the nme native library and setup a callback for when the graphics are finally initialized.  You then return to Java code and setup a OpenGL ES context.  When this is done, a JNI call is made into the nme dynamic library, which in turn calls back into your haxe application to complete setup.  The &#8220;MainLoop&#8221; is then processed in Java, and events such as &#8220;Redraw&#8221; (and later &#8220;OnMouse&#8221; etc) are passed into the nme library, and then into the haxe application as registered &#8220;addEventListeners&#8221;.</p>
<p>So in this somewhat convoluted way, Java maintains full control of the app, and therefore correct interaction with the OS, while almost all the real work is done in the haxe code.   In the example shown here, no changes were necessary to the haxe code, and the internal garbage collection also worked without modification, so it is a pretty solid cross-platform solution.  </p>
<p> Now the bad news.  The performance is way down compared to my 2nd generation iPod touch.  This example is 10fps on the Android device, and about 24 on the iPod.  Which is strange, because the core should actually be running a bit faster.  The slowdown seems to be on both the OpenGL side, and the physics calculation side.  It should also be noted that this is a first pass, so there is quite a bit of room for improvement.  My guess is that the gcc compiler is generating significant runtime overhead per function because of the exception code.  This is what I noted while compiling for the iPhone (it was doing a pthread lock per function!) \- but in that case the penalty was only incurred in functions that actually &#8220;threw&#8221;, so I simply moved the throwing code into a separate function.  Which brings me to my second problem &#8230;</p>
<p>No easy profiling or debugging support for native code.  This is a real pain for debugging (back to &#8220;log&#8221; debugging) and the lack of profiling makes it very hard to work out what needs optimizing for the target.  I may be able to use a simple &#8220;setjump&#8221; style system for exceptions because the use of garbage collection means that there are no real destructors required for cleanup. But I would need to be sure this would help &#8211; premature optimization and all that.</p>
<p>I would also count the fact that you really need to use eclipse as an IDE as a big negative, but I think that this is just my personal dislike of the program.  I think there may ultimately be ways around this with command-line compilers etc.</p>
<p>Native compiling tools for the Android target are still in active development and moving forwards, so I&#8217;m assuming that most of these problems will be overcome eventually.  And of course, the big advantage of the Android OS is the openness \- so I can provide you with the actual application to run on your device \- <a href="http://gamehaxe.com/wp-content/android/hxAndroid.apk">give it a go</a>, and let me know if it runs for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/06/28/android-port-first-light/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>JavaScript &#8211; ready or not.</title>
		<link>http://gamehaxe.com/2010/05/25/javascript-ready-or-not/</link>
		<comments>http://gamehaxe.com/2010/05/25/javascript-ready-or-not/#comments</comments>
		<pubDate>Tue, 25 May 2010 16:31:49 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[neko]]></category>
		<category><![CDATA[nme]]></category>
		<category><![CDATA[Result]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[v8]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=297</guid>
		<description><![CDATA[JavaScript Performance There have been some very promising improvements in JavaScript performance, but exactly how good is it? It turns out, that there is a pretty easy way to work this out &#8211; thanks to haxe. Haxe allows the same &#8230; <a href="http://gamehaxe.com/2010/05/25/javascript-ready-or-not/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>JavaScript Performance</h2>
<p>There have been some very promising improvements in JavaScript performance, but exactly how good is it?  It turns out, that there is a pretty easy way to work this out &#8211; thanks to <a href="http://haxe.org//">haxe</a>.</p>
<p>Haxe allows the same code base to be compile to Flash, JavaScript, neko and cpp.  The graphics is handled differently &#8211; Flash uses its plugin, JS uses canvas and neko is using the NME library, running opengl.  To compare these, I&#8217;ve chosen the Physaxe library, which is optimized for all these platforms, and can give a feeling for an app that has a computational and graphics load.</p>
<p>Into this mix, I will add another interesting option:  The V8 JS engine, running using the NME library in opengl mode.  This cross-over mode is actually quite easy to implement because of 3 stars aligning:  1. The NME library has a external interface that uses opaque handles that map very naturally to the v8::Value *.  2. The haxe compiler makes it possible to program JS without losing your mind, and all the existing library code is valid for this target. and 3:  The Google V8 JS engine has a clean API that makes it easy to embed (you would almost think they designed it that way &#8211; dispite the frugal documentation).</p>
<p>The benchmark I have chosen is the &#8220;Pentagonal Rain&#8221;, which is nice and stressful for the CPU.  You can try for yourself &#8211; use the &#8217;5&#8242; key to switch to this demo.</p>
<ul>
<li><a href="http://gamehaxe.com/wp-content/physaxe/js-web/physaxe-js.html">JavaScript Canvas</a>
<li><a href="http://gamehaxe.com/wp-content/physaxe/swf-web/physaxe-flash.html">Flash</a>
<li><a href="http://gamehaxe.com/wp-content/physaxe/physaxe-win32.zip">Win32 Binaries (Neko, V8VM, CPP-compiled)</a> (extract and drag the &#8220;.n&#8221; file onto neko.exe, or drag the &#8220;.js&#8221; onto the v8vm.exe)
</ul>
<table>
<tr>
<th>Engine</th>
<th>FPS</th>
</tr>
<tr>
<td>Neko/nme</td>
<td>9</td>
</tr>
<tr>
<td>Chrome 4.1, JS</td>
<td>11</td>
</tr>
<tr>
<td>Opera 10.5.3, JS</td>
<td>18</td>
</tr>
<tr>
<td>V8VM/nme</td>
<td>23</td>
</tr>
<tr>
<td>Flash</td>
<td>37</td>
</tr>
<tr>
<td>CPP/nme</td>
<td>130</td>
</tr>
</table>
<p>So as you can see, the V8VM option is actually quite viable as a scripting vm.  Since there is <em>a lot</em> in common between neko, v8vm and cpp haxe targets and plugin architectures, it should be relatively straight forward to switch between them.</p>
<p>The JS demo <em>can</em> run on the iPhone.  But just because you can do something, it doesn&#8217;t not mean you should \- at about 2 FPS on the title screen, I can&#8217;t imagine how slow it would run in the Pentagonal Rain demo.  And probably not great for your battery either <img src='http://gamehaxe.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/05/25/javascript-ready-or-not/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Bravo, Apple</title>
		<link>http://gamehaxe.com/2010/04/10/bravo-apple/</link>
		<comments>http://gamehaxe.com/2010/04/10/bravo-apple/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 09:46:34 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[Haxe]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=284</guid>
		<description><![CDATA[Finally, Apple is doing away with those arrogant upstarts who think then can write a few lines in a high level language and call it a program. Their new developer agreement requires: 3.3.1 – Applications may only use Documented APIs &#8230; <a href="http://gamehaxe.com/2010/04/10/bravo-apple/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Finally, Apple is doing away with those arrogant upstarts who think then can write a few lines in a high level language and call it a program.  Their new developer agreement requires:</p>
<blockquote><p>3.3.1 – Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).</p></blockquote>
<p>This has a couple of good points &#8211; firstly banning stupid languages (used by those people who are not smart enough to learn c++), and secondly getting rid of translation layers. Apple has clearly put a lot of thought into their APIs, so why would anyone want to put a layer on top of them &#8211; it&#8217;s just going to make things harder to use.</p>
<h2>Languages</h2>
<p>There has been a lot of talk recently about compiling &#8220;foreign&#8221; languages, such as haxe, as3, javascript, java, .net based languages, into binaries that will run extremely well on the iPhone.  But like all foreigners (who are responsible for all the terrorism in the world) these languages should be cleansed from all iPhones to maintain the iPhones mono-lingual purity.  Putting such insidious diversity into a beautifully designed device can be shown to confuse consumers, <em>most of whom don&#8217;t even know their device and been compromised by these so call &#8220;high level&#8221; languages</em>.</p>
<p>By raising the barrier of entry, and only permitting &#8220;real&#8221; programming languages (ie, &#8220;C&#8221; based ones), Apple ensures that the quality of apps will remain at its current lofty levels.  &#8220;Natural Selection&#8221; will then weed out those people who are  too lazy or too stupid to learn a proper language.  In fact, I think Apple has not gone far enough here and should dabble in a bit of &#8220;Intelligent Design&#8221; by requiring that all developers who wish to submit apps hold at least a 4 year degree in computer science.  Just imagine a world where any kid can work out of his garage and build an application with an <em>original</em> language, or bit of hardware, that snubs its nose at the establishment &#8211; anarchy would ensue.  Therefore, it is important that the responsible companies out there vet such potentially disruptive ideas before they can cause too much damage.</p>
<p>It can&#8217;t be said that Apple don&#8217;t like new langauges, after all, they championed the greatest NeXT Step in programming ever, Objective-C, it&#8217;s just that all the other languages are utter crap.  Some of then do away with the beautiful square bracket, some use commas to separate function arguments and nearly all the modern ones perform &#8220;Garbage Collection&#8221;.  What a joke!  Apple solved this problem years ago be simply <em>not creating garbage in the first place</em>.  Again, it is only those too lazy to learn about how to use allocation pools and correct reference counting that need anything as dirty as Garbage Collection.</p>
<p>The new langages, such as haxe, are so terse that you do not even know when you are using a delegate.  How can anyone possibly understand that code like:<br />
<code>addEventListener(KeyboardEvent.KEY_DOWN, function(event) { trace(event); });</code><br />
Is supposed to do?  I mean where is the delegate? Where is the class that implements the UITextFieldDelegate protocol? (And why must these languages continue to call things &#8220;Interfaces&#8221; when they are clearly &#8220;Protocols&#8221; ?)</p>
<p>I think Apple are right to ban code generators, such as the haxe c++ backend.  While these produce code that could in theory be produced by hand, the code it robotic and lacks the &#8220;soul&#8221; of hand written code.  To err is human, and without the quirks introduced bu a human coding c++ we may as well hand the future over to SkyNet and let the machines run everything.</p>
<h2>Layers and Tools</h2>
<p>Thankfully, Apple has also done its research into programming techniques as well as programming languages. The problem with programming these days is that where are too many layers and tools to learn, and they are taking us back to a simpler times where you are &#8220;close to the metal&#8221;.  Apple rightfully shuns these extra layers, and focuses only on code.  Once you understand Objective-C, Interface Builder, NIB, XIB, Frameworks, .app layouts, provisioning, xml, plist, controllers, delegates, owners and outlets, then you can create pure lovely code, without any of that layering crap getting in your way.</p>
<p>Programmers must beware of code that essentially &#8220;lies&#8221; by pretending that the beautiful, native API actually looks like one of the ill-conceived APIs from another language.  For example, why would anyone want to view a native UIView image as the practically unsable as3 &#8220;equivalent&#8221; (I use the term loosly) of BitmapData?  I don&#8217;t think there is a single successful application ever written that uses this BitmapData class.</p>
<p>Isolating your code from the native API will cause your code to lose its identity.  If you can compile it for another (obviously inferior) device then your code will become tainted by the lower class device, even it it performs identically on the Apple device.  How quickly people forget that the upper class should not mingle with the lower class.</p>
<p>I hope Apple&#8217;s ban extends to the gzip &#8220;translation layer&#8221;.  Programmers should not be using this library because it has security implications, and they should simply use the streaming classes and do the decompression in their own code.  If more programmers thought like Apple, then there would be a lot fewer security holes in software.</p>
<p>Don&#8217;t get me started on Game Making programs.  Thank god these are banned &#8211; imagine letting a non-programmer create an App.  What next, Artist creating games?  Don&#8217;t make me laugh.</p>
<h2>Conclusion</h2>
<p>Apple has made a huge stride forwards by tightening the definition of what a real developer is, and I&#8217;m looking forward to what&#8217;s next.  I think they have a little way to go &#8211; for example, what about all those people using foreign editors, rather than XCode?  Surely if XCode is not good enough for a developer, then that developer is not good enough for Apple.  The best way I can see for them enforcing this is for them to install a &#8220;watchdog&#8221; application the the developer&#8217;s machine, and send screenshots back to Apple periodically.  That way, if the developer does not conform to the coding purity required by Apple, they could be identified and sent to a camp to help them concentrate on being better programmers. Win-win, what a great idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2010/04/10/bravo-apple/feed/</wfw:commentRss>
		<slash:comments>135</slash:comments>
		</item>
		<item>
		<title>Switched to IMMIX for Internal Garbage Collection</title>
		<link>http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/</link>
		<comments>http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 12:39:37 +0000</pubDate>
		<dc:creator>Huge</dc:creator>
				<category><![CDATA[hxcpp]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[immix]]></category>

		<guid isPermaLink="false">http://gamehaxe.com/?p=230</guid>
		<description><![CDATA[I did a little bit of profiling on the iPhone and found a bit too much time was spent doing garbage collection. The hxcpp runtime has 2 modes &#8211; &#8220;Boehm GC with explicit statics&#8221; and &#8220;internal&#8221;. The former is from &#8230; <a href="http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I did a little bit of profiling on the iPhone and found a bit too much time was spent doing garbage collection.<br />
The hxcpp runtime has 2 modes &#8211; &#8220;<a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">Boehm GC</a> with explicit statics&#8221; and &#8220;internal&#8221;.  The former is from a standard and robust code base, with the latter uses built in code with explicit marking.  I added the second mode because Boehm GC was just too slow on the iPhone &#8211; not sure why because it is pretty good on the other platforms (maybe I missed a configuration option).</p>
<p>The internal GC has some restrictions that make it mainly suitable for games.  These are: the collection must be triggered explicitly, since no stack searching is done, which is most easily done once per frame.  And it is not thread safe, which can be worked around.  Within these confines, many different schemes can be tried.<br />
My first attempt could probably be termed &#8220;Naive Mark and Sweep&#8221;, and used free lists.  On Windows/Mac this underperfromed Boehm GC, but on the iPhone, worked better.</p>
<p>The current scheme is now &#8220;Simplified <a href="http://www.cs.utexas.edu/users/speedway/DaCapo/papers/immix-pldi-2008.pdf">IMMIX</a>&#8220;.  It is simplified because it is single threaded, and I have not implemented overflow allocation, defragmentation (although there are hooks in there for moving) or any generational stuff.<br />
I think overflow allocation should be easy enough, and defrag should not be too hard in some form or other.  The insertion of write barriers for generational control may also be straight-forward using the &#8220;operator =&#8221;.  I may also change the code generation to separate stack variables (local, function args) from member variables since in the current scheme, stack variables never form roots, and therefore would not need to use write-barriers.</p>
<p>Anyhow, on the &#8220;Physaxe&#8221; test, which creates lots of small list objects per frame, the Naive GC got about 51fps, Boehm GC got about 65fps and IMMIX got about 69fps &#8211; so a bit of a win there.  For this test, I triggered all collections exactly once per frame.  The difference between Naive and IMMIX is significant, and this perfromance gain also translates to the iPhone, which is good news.</p>
<p>Since the internal scheme is precise, I feel it should be able to outperform Boehm GC by a bit more, and maybe the extra could come from a generational system.  The code is actually not that complex (1 cpp file, 1 header file) so any budding GC researchers may want to see what they can do.</p>
<p>Currently, the internal GC is default only for the iPhone, but you can try it on other platforms by changing the #define in hxGCInternal.h.  The reason for this is the restrictions mentioned above &#8211; the easiet way to conform to these restrictions is to enable the &#8220;Collect Every Frame&#8221; in neash.Lib.  To remove these restrictions, I will need to find some way of stopping the world (safe points?) and some way of capturing the stack (code mods to allow objects to push themselves on a shadow stack?), both of which are very doable, although I&#8217;m not sure on the effect on performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

