MagicLeap One: Why you want to use C/C++ instead of Unity?

Roger Boesch
4 min readDec 16, 2019

90% of all the apps and games on the MagicLeap One are created with Unity (and a few with Unreal). It’s therefore not a surprise that almost all information, tutorials and available examples are focused on those two Game Engines. I want to change this and start a small series of articles on how to create a game in C/C++ using just the C-API of Lumin OS.

Lumin Runtime API
Besides the support of Unity or Unreal there is also Magic Leap’s own engine called Lumin Runtime. It’s more or less a C++ wrapper around the pure C-API and a kind of application framework that simplifies creating an App in C++. Conceptually it’s very similar to SceneKit from Apple and uses similar to it also a Scene Graph approach. From my point of view it’s a great fast-starter but when it’s about port C++ from another platform or create something highly optimised and fast (like your own game engine), a better solution is to use directly the C-API, which gives you full access to the platform. That’s what we will do together in the upcoming articles!

Why YOU should use C/C++ or not!
Because we can ;) I'm just kidding, in fact there are good and real reasons to do so, but of course there are also some disadvantages going that way.

At first why you should use C/C++:

  • You have existing code from another platform
  • You really want to understand and learn the platform and API
  • You want to create a Landscape application (Currently not possible with Unity or Unreal)
  • You want use and/or learn how to use OpenGL in AR/VR
  • You want better understand how VR, AR and Spatial Computing works

And when you should absolutely not use C/C++:

  • You are more interested on the gameplay itself and not about the underlying technology
  • You want to finish a game or app in the shortest time possible: Go with Unity. It’s so much faster and easier to create an experience, especially when it's your yours first one
  • You have an existing Unity project you want to bring to the Magic Leap One
  • You hate linear algebra :)

Why I use C/C++?
Everyone who follows me on LinkedIn knows that I’m a big retro gaming fan and work in my free time purely in C/C++ and mainly with Pixel Art or Retro style 3D Graphics. Also I love the game machines from the 70’s and 80’s like the Atari 2600 or the Vectrex. I write on my own game engine and have even written some emulators to still play my favored games from my childhood. Of course all in C++ and C… And so when I first worked with the ML1, the idea was born to create a Vectrex emulator for it.
Unfortunately during my time at Magic Leap I was always to busy to do it and the idea is waiting since then in my always growing backlog of ideas, lol.
Until now!

Learn to really understand the Platform and Lumin OS
As I wrote above, there is almost no info about C/C++ programming for the ML1. Even in the SDK you find just very basic C examples. I want to change this. Instead of writing now just the emulator I’ve decided to create besides some articles that describe this process and are hopefully also helpful for others in search for this kind of information.

What you will learn?
We will create a very basic game engine and even a simple 3D game. Besides that you learn how OpenGL is used to create the awesome spatial experience and the wow effect everyone has, when first time see and use it. And last but not least, you will learn and see that it’s not so difficult and different to any other 3D platform to create a game just in C/C++.

Tutorial:

  • Part 1 — Tool Setup and first step
  • Part 2 — Render objects and use of the controller
  • Part 3 — Create a simple game: MazeRace
  • Part 4 — Improving MazeRace and macOS Bonus Code

Disclaimer:
All the information used in my tutorial are available for everyone in the public API. Also all the opinions are my own and not necessarily the same as those of my former employer Magic Leap.

Important: Please also don’t ask me anything about Magic Leap. I’m a passionate 3D Software Engineer and as such a big fan of the device, SDK and platform. I love to work on VR and AR in general and devices like the Magic Leap One or Hololens 2 are clearly some early ideas on what we can expect in the future to see. Don’t give a sh… on all the different press releases. Get a device by yourself, write code on it and start to become an idea of how the future of Apps and Games might look like. It’s at least a great investment in your personal education. I hope I can give some useful information with this tutorial and hopefully the following articles helps you to build your own and better opinion. In that sense: Happy coding!

Visit also my blog at rogerboesch.com where I write about retro game development for the machines of the 80s like the Sinclair ZX Spectrum, Vectrex, Atari 2600 and many others.

--

--

Roger Boesch

Software Engineering Manager worked for Magic Leap, Microsoft and NeXT Computer - 8 years experience on spatial computing