Compile angle project from source on mac os x

For those who don't know ANGLE project is not a microsoft one which apparently is first in result when I type it on duckduckgo but google founded Almost Native Graphics Layer Engine that is part of, to name a few: Chrome, Firefox or Qt. It's great piece of software I always wanted to dig into because it's behind webgl engine of chromium project.

I had some inconsistency in great getting started document so I would like to provide step by step guide how to simply run hello_traingle. I assume you got at least git installed. I don't know if I got any more dependencies.

Let's start by downloading 2 repositories next to each other:

The actual angle project repo:

git clone https://chromium.googlesource.com/angle/angle

And build tools:

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

So we want to make those tools executable from angle directory so we will either do it once by executing:

export PATH=\`pwd\`/depot_tools:"$PATH"

or add path of depot_tools directory to ~/.bashrc if you want permanent change.

Next commands we will execute in angle directory location. So simply

cd angle

After that on mac os x or linux we want to change our default renderer therefore edit

src/libANGLE/renderer/d3d/DisplayD3D.cpp

with your favourite renderer and change 1 to 0:

#define ANGLE_DEFAULT_D3D11

and then simply run some commands to sync our project using this magic:

python scripts/bootstrap.py        
gclient sync                        
git checkout master             

The last thing we need to do is setup gyp generators:

GYP_GENERATORS=ninja gclient runhooks

and at the very end after making path

mkdir -p out/Debug

compile it:

ninja -j 10 -k1 -C out/Debug

if you find out error that is something like this:

ninja: error: loading 'build.ninja': No such file or directory

just repeat GYP_GENERATORS=ninja gclient runhooks and then ninja -j 10 -k1 -C out/Debug part.

if everything is ok you will see something like this

ninja: Entering directory 'out/Debug'
[147/1307] CXX obj/src/compiler/translator/translator.TranslatorGLSL.o

and after it finished compilation you can see triangle by executing

./out/Debug/hello_triangle

Here it is:

angleproject triangle image

I hope you managed to do it. Enjoy