Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to port c++ game to web [closed]

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?

like image 608
DavidColson Avatar asked Dec 27 '22 20:12

DavidColson


2 Answers

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. https://github.com/kripken/emscripten/

like image 74
Endre Simo Avatar answered Dec 29 '22 08:12

Endre Simo


I would strongly suggest porting to NaCl.

Advantages:

  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.

Disadvantages:

  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.
like image 21
codetiger Avatar answered Dec 29 '22 08:12

codetiger