I'm developing small game using c++ and OpenGL. I would like to post it also in Chrome Web Store.

I've seen that a lot of apps are just redirection to specific url. I can use Java Applet and JNI to launch it in chrome, but that would be only waste of memory.

  • \$\begingroup\$ Yes it is possible. \$\endgroup\$ – Lorenz Lo Sauer Nov 6 '13 at 19:21

For best results, you'll want to create a port of your application. A quick (and probably dirty) way to do that might be using Google native client (allows running natively compiled code in the browser).

Otherwise you'll have to take the long road of porting your code from C++ to Javascript Dart or pure HTML5.

  • \$\begingroup\$ +1 for native client, almost a -1 For even suggesting that porting to JS/HTML5 is a sane thing to do. JS is horrible for games; check out Dart at the very least if you want to go the "pure HTML5" route. \$\endgroup\$ – Sean Middleditch Aug 3 '12 at 21:58
  • \$\begingroup\$ @seanmiddleditch Good points, I haven't used Javascript for much. Good to know it's something to stay away from. Modified the answer to reflect that. \$\endgroup\$ – MichaelHouse Aug 4 '12 at 0:55

Emscripten is the best way to do this as of today. It can compile pure C++ code into a subset of JavaScript called asm.js which is very efficient and can be even further optimized. As of today only Firefox has explicit optimizations for asm.js, but the compiled code will run (quite well) on every major up-to-date browser (even IE!) and can be used in the Chrome Web Store.

It requires that you use OpenGL ES 2.0 for graphics (since it uses WebGL in the translation, which is roughly equivalent to GLES2). It is easy to use SDL for windowing and input as Emscripten natively supports bindings for that, though some other common toolkits are also supported; for any other libraries you'd need to do the binding yourself. I/O, audio, networking, and so on are supported. Threading is not yet supported but work is underway to handle it.

There are a few small things you need to do for a basic port (especially regarding the main loop, as JavaScript has its own internal main loop you must use) and more advanced applications may need some additional special porting work, but in general it's not too bad.

Note that even big game engines like Unreal have been ported to the Web via Emscripten, so it's very much a viable and production-ready toolset.

There are some other C++-to-JS transpilers out there, but Emscripten is the most well-known and developed right now.

  • 1
    \$\begingroup\$ Interesting as emscripten it is, Firefox-only makes it a poor choice for the Chrome store, no? \$\endgroup\$ – Seth Battin Nov 6 '13 at 21:54
  • \$\begingroup\$ @SethBattin: It's not Firefox only. \$\endgroup\$ – Sean Middleditch Nov 6 '13 at 22:51
  • \$\begingroup\$ Edit noted :) I recalled that was previously a limitation of the Unreal demo. \$\endgroup\$ – Seth Battin Nov 6 '13 at 23:47
  • \$\begingroup\$ Yeah, that was as I recall a bug in the version of Chrome out when the demo dropped, not a fundamental incompatibility or missing feature. \$\endgroup\$ – Sean Middleditch Nov 7 '13 at 0:08

Of course, Google's Webstore policy allows it.

There are many offerings which require an additional native executable to be installed by the user in order to aid the browser extension with information.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.