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.
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:
You can see the project page here, with working examples. https://github.com/kripken/emscripten/
I would strongly suggest porting to NaCl.
- 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.
- There are a lot of already ported examples, games for NaCl that can help you do it easily.
- It is already cross-platform. Chrome runs on Windows, Linux, Mac OSX.
- 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)
- Runs only on Chrome.
ActiveX and NaCL are just not portable in any way, shape or form.
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)