Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

11. June 2011


EDIT: Now with video!


After yesterday’s post, I noticed there wasn’t a recent build of Avocado available so I got to wondering how much work it would be to build a Blender branch.  In the end the answer is “not much”, with a bunch of caveats.  Frankly the hardest part is configuring your environment.  This guide shows but one way, there of course are other options.


First of all, I already have Visual Studio 2010 Professional installed, but many of you may not have professional and there is a big snag with Express C++ in that there is no command line 64bit compiler.  At this point you have one of three options, build for 32bit, download and install the Platform SDK which includes a 64bit cross compiler or you can download and use mingw.  The last two options are beyond the scope of this post and the instructions will assume you are using VC++.


Next up you need SVN, which is what you use to get the code from Blender’s repository.  In my case, I am using Cygwin from the command line.  For those of you with a command line aversion, you can use a GUI tool like Tortoise SVN.  Again, my instructions are going to assume you went the Cygwin route, but should still make sense a different SVN.


Now, to get Cygwin, run the Setup.exe ( from here ) and choose the default ( install to a directory without spaces! ).  You can add other features, but don’t do this now as some download locations don’t have all the packages, so it could result in your install failing.  Once setup.exe has completed, run it again and search for svn, if it is not installed ( as pictured below ), in the New column, instead of keep it will say “Skip”, click this and it will set it to download.  Then click next and it will figure all of the requisites and dependencies, download and install them.




Assuming all went well, you now have svn.  Only one more file to install, CMake, a cross platform make tool.  The install process is pretty straight forward, now time to grab the sources.  You are going to need to make two directories on your local computer, one where the code is going to be downloaded, then one where the code is going to be built.  In my case ( and in the instructions ) I used C:\Temp\Blendersource and c:\temp\BlenderBuild but you can of course use whatever you want.


Now its time to get the source.  Launch “Cygwin Bash Shell”, it should be located in your Start Menu.  Otherwise you can run it from [Cygwin Install Directory]\Cygwin.bat.  Now you need to choose which repository you want to build.  The list of branches is available here.  In your browser navigate to the one you want to build, then into the blender directory and copy this address.  In this case I am building Avocado, so I copied to my clipboard.

SVN works in the form of:

svn checkout [ paste your clipboard ] [where to copy to]


One gotcha is you need to point BASH to a directory on your computer, in this case C:\temp\blendersource.  In order to do this, we use the /cygdrive link.  So, the actual command looks like:


$ svn checkout /cygdrive/c/temp/blendersource/


That will go ahead and download all the blender code.  You will probably get an error stating server certificate isn’t trusted, check type “t” or “p”.  Later on you are going to need the precompiled binaries from the trunk repository.  They are located at in the windows/ and win64/ folders.  Warning! This takes a long time, like go make and drink a pot of tea long time.  We want them copied into the /lib/windows directory of the newly downloaded source.  The command for this is:


$ svn checkout /cygdrive/c/temp/lib/windows

followed by:


$ svn checkout /cygdrive/c/temp/lib/win64


At this point, you have all the sources and libraries you need.


Now fire up trusty CMake you downloaded earlier.  In the “where is the source code:” text field put C:/Temp/blendersource/ ( or the location of CMakeLists.txt if you are using a different path).  In the “Where to build the binaries:” text field put c:/temp/BlenderBuild.  Now click “Configure”, the following window will appear, select your compiler:





Click Finish once your compiler is selected from the list.  Now your CMake window should look like this:



Now you can optionally enable/disable features.  If building Avocado, disable WITH_IMAGE_OPENEXR! It will currently cause your build to fail. Once you finalized your selections click Configure again, then Generate.

Now if you look in C:\Temp\BlenderBuild, you will see that CMake has built the proper native build files, in my case for Visual C++ 2010.  There is even a solution file if you want to build using the VC IDE.  In this case I am going to use the command line, launch the Visual Studio X64 64 Bit Command Line.  Now type:

cd \temp\blenderbuild

msbuild Blender.sln /property:Configuration=Release


And off to the races…   See, nothing to it! Open-mouthed smile


After 5 to 20 minutes later, copy your new Blender.exe ( from bin\release ) into a Blender install and…




AHHHH crap, seriouslyjQuery152044251238950528204_1314637985251?  Well, we apparently have a very streamlined version, perhaps a bit too streamlined.  What exactly is going on here?  Well, truth of the matter is, if you followed along at home and aren’t using Windows 7, nothing, it probably works perfectly fine.  However, if you are like me and are running Windows 7, this post is very interesting.


There is some annoying permissions issue with Win 7, depending on who/how/where you install as. A known problem, being worked on. Maybe already fixed. (can you tell I'm not a windows guy?)
Easiest work-around for now is to download the .zip version, unzip it and run from that folder.


Welcome to life on the bleeding edge!  It’s called the “bleeding edge” for a very good reason!  Anyways, head over here and download the 64bit ZIP install, extract it and copy your new Blender.exe file over.   Voila!





A fresh new 64Bit version of Blender—Avocado, bmesh tools and all.  It may have looked difficult, but in the end, it really isn’t, with the exception of figuring out the most recent bug ( thanks Google ).


Seem like too much work?  You can download the blender.exe I generated.  Simply download and install the current 2.57b ZIP from Blender, extract it then extract my over top.

Art, Programming

10. June 2011


One of the nicest features of going with Blender is the fact that it is open source.  One of the nicest facts of open source is you don’t have to wait for a vendor to release a new version, you can go get the cutting edge version at any time.  That said, building Blender from scratch is a non-trivial task, but nicely for that we have


Basically graphicall allows people to post and share their builds.  You go on the site andBlogEngineLogo choose a build to download.  You can choose by OS, bit-ness or the various features included in the build. Why the heck would you want to do this?  Well, frankly some of these features are incredibly interesting, but perhaps most interesting of all, is the new BMesh tool.  Remember how I said earlier that the weakest link in Blender was the modeling tools, and the one feature it was missing the most was the lack of n-gons?  Well, bmesh addresses this shortcoming.  It is rumoured that it will be part of Blender 2.8, but it as been in development for a very very very long time, so don’t hold your breath. I will hopefully have a demonstration up shortly that illustrates this powerful tool.


But bmesh is by no means the only thing to look forward to.  Another area graphicall builds cover is Google Summer of Code builds.  If you have never heard of it, instead of getting a summer job, students instead propose a project in the open source world and if approved, get paid by Google to implement it.  This year, Blender is a pretty big winner on the number of projects sponsored.  About half of the projects on that list will be a huge boon for game development.  The various branches can be viewed here.


A quick trip to GraphicAll is going to confuse the hell out of you though…  Avacodo? Radish? Cucumber?  WTF?  Well lets just say the Blender group like their code names!  Last time it was fruit, this time, it’s veggies.  Anyways, this infographic that I brazenly stole from here which in turn they stole from here.  Anyways, it’s a good image, so here goes(click image for original).





Anyways, probably of most interest from a game perspective are the Avocado, Onion and Pepper branches.  Of most interest to game dev work is the Avocado branch, which is the only one based off the BMesh branch instead of the main trunk fork ( Salad branch ).


But by no means are we confined to the Summer of Code builds, lots of other stuff is available as well.  There is Blender Cycles a GPU based render, LuxBlend interface for LuxRender, Yafaray as well as builds using OpenMP for better multicore CPU support.


So, if you are willing to take a walk on the wild side and put up with a few more bugs and glitches, Graphicall is very much worth checking out!


5. June 2011


When I was starting out, I was just dying to earn my “real programmer badge™”.  At the time “real programmers” used assembly and I was taking the lazy easy way out using C.  So, in my quest to earn my real programmer badge I taught myself assembly.  Now it took me 10 times as long to write my code and it sure was more difficult; no doubt my badge would be in the mail!  Sadly… no, it didn’t arrive.



The years went by and assembly became more and more niche.  In the meanwhile, higher level languages came to the fore.  There were even languages that hacks and simpletons could rapidly create programs in, like Delphi ( pascal ) and Visual Basic.  Of course real programmers looked down upon these amateurs, everybody knew that this wasn’t real programming.  Hell even C++ was looked down upon, it was way too high level and slow for real programmers to use, so being a real programmer I kept using C.  Things sure were slow and painful, lots and lots of work, no doubt my real programmer badge was on it’s way! 



Another generation of languages came along, new pretenders like Java and C# rose in popularity and the lazy and weak flocked to them like mad.  Real programmers of course knew that C++ was the one true language.  Sure, those class libraries and the freedom from memory management sure looked tempting, but I am a real programmer damn it, so I continued working in C++.  My god was it difficult so I truly must be getting close to getting my real programmer badge.  When it didn’t arrive I decide their surely must be a mistake at the post office!



Then the current generation of languages came to the forefront.  Scripting languages had risen in popularity, to the point that it seemed more people were “scripting” than programming these days!  Scripting?  What real programmer in their right mind would ever work in a lowly scripting language?  I am a real programmer, I will leave scripting for the hacks and newbies, thank you very much!  Real programmers work in C++!  Oddly enough, I still haven’t received my badge…?



Recently a funny thing happened… I took to a project under a tight deadline, it absolutely had to ship on a given date.  There was no way I could possibly succeed in time using a real programming language, so I took to using the plebian tools.  Working in C#, the wonderful class libraries sure did make development fast.  At times I actually slunk to the lowest of the low and used scripting languages!  It felt so dirty but I have to admit the rapid turn around and interactive tools sure did things quick.  In the end, it was a challenge and I had to prostitute my pride, but I shipped on time!  The following day, a FedEx truck pulled up to my front door and delivered my prized Real Programmers Badge™!






( Image totally stolen from a middle aged drama queen. )

Of course, this story is completely full of crap but the moral is completely true.  When I was starting out C was truly looked down upon as being a tool of “fake” programmers. Through the years the language has changed but there has always been an “IT” language that new programmers to the field think they have to work in to be a real programmer.  It sadly often takes years of experience to realize how stupid this mindset actually is.  Can you imagine a carpenter that wouldn’t use a drill because “real carpenters” use screw drivers, would you hire this person?



A real programmer uses the right tool for the job.  For those of you just starting out, “the job” very much includes “learning to program”.  In the end a real programmer makes the best product they can, as efficiently as they can, using whatever tool works best.  Sometimes, that tool might even be C++!

Programming ,

30. May 2011


So, until this point I have been using Microsoft’s Expressions Encoder to do video capture for tutorials on this site.  I am an MSDN subscriber and already had the Expression Studio installed, so even though I was really (…….. really ) pushing the bounds of my license I went ahead and used it.  Then I ran into a pretty big snag, see the encoder that ships with my Expression Ultimate version is the “free” version, which you can download here.  It is an impressive product, that makes for very small file sizes that are surprisingly detailed.  That is, until you hit the 10 minute mark.  That… is a sizable gotcha.


So, I started looking into alternatives.  Camtasia Studio is easily the big player in this space, but with a pretty severe 350$ price tag.  The before mentioned Expressions Encoder can be had for a more modest but still too high 200$.  The I found Cam Studio which is a free and open source alternative, but it really wasn’t a viable option.  My first test was 15 seconds long and a little over a GB in size!  Plus frankly, it looked awful.  I just don’t think Cam Studio is set up to do HD video.  I played around with various codecs and settings but frankly never got anything that approached usable. 


I was really starting to fret that I would have to put out a couple hundred bucks to simply capture video and frankly me and my money are rather tight friends and don’t want to part so easily.  Then a moment of serendipity occurred… I came across a shareware product called FastStone Capture which effortlessly recorded my screen, at > 15FPS directly to WMV.  After a minute of recording at 1080p I was well under 20MB!  What is so serendipitous about that you ask?  Ironically enough, I had already purchased this product a couple years back for helping me with screenshots!  SCORE.


Anyways, if you are looking to do video/screen capture on a Windows machine, I highly recommend you check out FastStone.  Comes with a fully featured trial and is only 20$ if you register it.  Keep in mind, it is NOT a video editor and isn’t even in the same league as Expressions Encoder or Camtasia for features, but if you want to just capture the screen in a high quality but small size, this is the best product I’ve seen.  Actually as I am using Blender for NLE and not Expressions, my work flow just became a heck of a lot faster, as I lost an encoding step!

Totally Off Topic

29. May 2011


Well here is one out of nowhere.  StudioGPU have released their flagship product MachStudio Pro 2 for free.  Real free too so far as I can tell, not free with an asterisk free.  For those of you that have never heard of MachStudio, it is in very rough terms a near to realtime renderer that makes use of your GPU.  In their own words:


StudioGPU's MachStudio Pro reinvents the 3D visualization production pipeline by putting the power of real-time graphics processing at your fingertips.

Render times that typically take hours or days are reduced to minutes and even seconds, limiting artists only to the scope of their creativity.

MachStudio Pro lets you truly Work at the Speed of Thought!



A Blender exporter is coming soon, but for now it does support importing FBX files.  Previous to this announcement, MachStudio sold for 4 grand!


Now the downside… you need a 1GB Direct X 11 GPU to run it.  In the world of desktops, that’s not too demanding.  For people like myself that buy only laptops, then it gets a bit trickier.  My best GPU is currently 512MB, but I am downloading it anyways to see what happens.


At that price though, if you have the system to run it, what are you waiting for, go download it now!



For those who ignore minimum requirements, just an FYI, it simply refused to run on my non-DX11 card.


Month List

Popular Comments

HaxeFlixel Tutorial–Hello World
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

17. March 2017


Now that we have covered getting your development environment up and running, we are going to jump into our first HaxeFlixel application.  Let’s start from the very beginning and create a new application.  As mentioned in the Getting Started tutorial, we can create an application using the simple command:

flixel tpl –n “HelloWorld”

This creates a directory with a skeleton application to get us started.  It actually creates a bit more code then we need, we are going to strip it down to just two source files.



It is pretty much tradition to make your first program a simple Hello World application, so that is what we are going to do.  We will simply print the text “Hello World” on screen, but since this is ultimately a game we are creating here, we will also animate it!  Ok, code time, let’s start with Main.hx, the entry point of our application.  Here is the source code:

import flixel.FlxGame;
import openfl.display.Sprite;

class Main extends Sprite
   public function new()
      addChild(new FlxGame(0, 0, GameState));


One thing that might immediately seem awkward is that our Main class inherits from Sprite.  This is a throwback to the Flash development world, just think of a Sprite as “something that is visible on screen”.  When our Main object is created it’s constructor is called and really it does just one thing, creates a new FlxGame object passing our GameState class in as a parameter.  The first two parameters to the FlxGame constructor are the width and height of our game window.  In this case we didn’t specify a value, meaning the value from the Project.xml file will be used instead.  If you look at Project.XML (which was generated for you) you will see the lines:

   <!-- ____________________________ Window Settings ___________________________ -->

   <!--These window settings apply to all targets-->
   <window width="640" height="480" fps="60" background="#000000" hardware="true" vsync="true" />

   <window if="html5" resizable="false" />

   <window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />

   <window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />

Due to this configuration by default our application will have a resolution of 640x480, while on mobile devices we will instead use the full screen.  As you can see it’s possible to set multiple definitions using the if=”platform” conditional.  If you want to have FlxGame create a larger or smaller window you can either specify the value when creating your FlxGame object, or you can change it’s value in the <window> tag.  Ok, back to our code...

As mentioned earlier, we created a FlxGame object, which is the heart of your application and contains the game loop.  Every single game or game engine has a game loop in some form, it’s essentially a loop that runs over and over until your game is done and is responsible for polling input, updating the world and drawing graphics on screen.  We don’t actually use FlxGame directly however, our game is instead broken into multiple states.  We see this in action in GameState.hx, here is the source:

import flixel.FlxG;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.util.FlxColor;

class GameState extends FlxState
   var text:FlxText; 
   override public function create():Void
      text = new FlxText(0,0,FlxG.width,"Hello World",64);

   override public function update(elapsed:Float):Void
      text.y ++;
      if ( text.y > FlxG.height)
         text.y = 0 - 64;

This is the meat of our application.  You will notice that GameState inherits from FlxState.  FlxState is a very important concept in HaxeFlixel development.  Essentially you break your game logic up into a number of different states, how exactly you do do this is up to you.  A common division might be  Title Screen State, Game Playing State, High Score State, Game Over State for example.  Another option is to break your game up into screens, so instead have it look something like Splash Screen State, Main Menu State, Game Playing State, Game Credits State, etc.  Or alternatively you could break your game into levels such as Main Menu, Level One, Level Two, etc.  Really it comes down to whatever fits the structure of your application the best.  Just keep in mind that FlxState are the logical units for breaking down gameplay complexity into manageable pieces and if you hate the idea completely, no problems, you can just throw everything together into a single state if you prefer.

At the end of the day though, the FlxState is a pretty simple data structure with two primary tasks.  First, it contains all the “stuff” that makes up that portion of your game.  In this particular example that “stuff” consists of a single FlxText node, but it could contain dozens or thousands of objects.  Just realize when we call the add() method, we are adding to a collection of Objects contained in the FlxState class.  The second important part of FlxState is to provide a number of callback methods that FlxGame can call.  As I said earlier, FlxGame contains our main game loop.  Each pass through this loop however it calls a series of functions on the currently active FlxState, the most important of which are draw() and update().  It is through these two callbacks that your FlxState derived class is modified over time.  Let’s look back at our example and walk through the code.

First in our create() method, we call our parents constructor so we are properly set up and configured.  We then create a new FlxText object, which is a special sprite (aka, something visible on screen) object for displaying text.  In this case we display the string “Hello World” at 32px height in the default font.  Notice we used a call to FlxG to get the width of the screen.  FlxG is a special global helper class containing handy information such as width and height of the screen, the default camera, access to input and more.  You can also get read only access to the FlxGame class we created earlier.  Once we create our FlxText object, we format the text so it’s aligned in the center and drawn in red.  Next we call the add() method, adding the text object to the GameState.  Once added it will automatically be drawn every frame unless disabled.

Next we implement the update() method.  As mentioned earlier, this is a callback function that is going to be called by FlxGame every pass through the game loop.  The one parameter it receives is a Float with the amount of time that elapsed since the last pass through the game loop.  This is extremely handy as it enables us to determine just how fast our game is running.  In this particular case all we do is update the text object’s y coordinate ( we will talk more about coordinates shortly, don’t worry ) scrolling until our text is off screen, at which case we go back to the top and start all over.  Please note that this particular code will run at different speeds depending on how fact the device it runs on is!  We will look at ways to make the code run at the same speed on all machines in a future tutorial.  For now, when you run this code you should see:



In the next tutorial we will dive a bit deeper into drawing graphics on screen.


The Video

Programming , , ,

blog comments powered by Disqus

Month List

Popular Comments