Best way to port c++ game to web

I realize the above question is rather broad so I will narrow it down. I have a simple opengl c++ game engine that lives in a static library (could be converted to a dynamic lib).

I have been thinking of ways of getting it to run in web. From what I can see I could use ActiveX or Google NaCl to run the c++ code in browser. But these technologies do not seem easily cross platform? Or maybe I have misunderstood.

Another option I have seen is converting the engine to javascript and WebGL and running in an HTML5 canvas. Would this be slower than c++? It would be very cross platform though.

What do you think is the best option, or better yet is there any other option I have missed?

EDIT: what about a custom plugin similar to the unity webplayer?


There's actually several technologies out there to help with this. Here's three I've run across, but have minimal/no experience with:

There is a library created by @kripken which is still under development. It takes LLVM bitcode and convert into Javascript.

You can see the project page here, with working examples.

I would strongly suggest porting to NaCl.


  1. Performance: You can use the full power of the CPU to render your game. If your game uses good 3d graphics or physics, you can make it look smooth even on old system configs. The performance of NaCl is comparable to Native OS applications, it only looses nearly 5 to 10% of FPS when I compared the same game to Win32 version.
  2. There are a lot of already ported examples, games for NaCl that can help you do it easily.
  3. It is already cross-platform. Chrome runs on Windows, Linux, Mac OSX.


  1. Might take you around a week to port. You have to port to OpenGL ES 2.0 (However, it should be the same with any browser based methods, especially HTML5)
  2. Runs only on Chrome.

If you want something portable in a browser, then it has to rely on Javascript (and likely WebGL, although IE does not support that).

ActiveX and NaCL are just not portable in any way, shape or form.

I can't say which is easier, but you have an option of rewriting your game in Javascript, or using a tool like Emscripten to compile your C++ to JavaScript.

Note that if you use the latter, it's still not a silver bullet. You'll likely have to make lots of changes to your code (for example because the libraries and APIs used in your C++ game won't be available on the browser)

Need Your Help

EF - Foreign Key Reinserted if Entity Object is Used

c# entity-framework entity-framework-6

So I have this problem with EF when I create objects which have FK reference on another object that was retrieved from DB but from different DB context (see GetBlog method). The problem is that whe...

SQL select statement inner join

mysql sql select join

I hava a table Person and a table Club.