Monday, January 14, 2013

emscripten-qt progress: faster, better, many Qt + C++ demos in your browser!


Probably my final update to my series of blogs about trying to get Qt ported over to the wonderful Emscripten, so that a Qt + C++ app can be compiled to Javascript and HTML5, and so run in a browser.


So, since last time: first of all, I've finally settled on the name "emscripten-qt" over "QtGui.js" - the latter is probably a bit more descriptive of what the project actually is, but the new name pays homage to the projects that actually do all of the clever stuff!


Secondly, performance is much improved: by undoing an earlier pessimisation of mine (wince) and by profiling and then compiling a bunch of select files with full optimisations (emscripten doesn't use inlining when it optimises as it can bloat the code, but some classes benefit from it hugely), I've managed to get the "colliding mice" demo running in Firefox at several frames per second, rather than several seconds per frame :) An experimental blitter (toggleable at run-time via a checkbox) often improves this even further.


Thirdly, keyboard support is now vastly improved, with shift, ctrl, actual punctuation chars etc now implemented.


Fourthly, there is now a demo page! Check them out here! I've mainly picked the most interesting ones, either visually or in terms of interactivity, but may add some of the more "boring" ones in due course. I'm especially fond of wiggly, scribble and textedit, which showcase how your emscripten-qt app can be made to interact with the rest of the webpage.

"textedit" - with PDF export!

There's also been a lot of work on writing some helpers to make some of the synchronous dialogs etc (which Javascript cannot handle) more easily ported to asynchronous ones, and on making drag-and-drog asynchronous instead of synchronous (enabling demos such as the puzzle demo.)

I still have a few odds and ends and a lot of documenting to do (especially a porting guide, which would additionally require me to document emscripten-qt-sdl, which has been invaluable for flushing out all of the problematic synchronous dialogs etc), but after that I'll leave it for a while and get back to working on Kate's Vim mode :)