@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
@GDevApp
facebook.com/GDevApp
https://gdevapp.com
Node.js Paris – Fevrier 2015@GDevApp http://gdevapp.com
From a native app to a webapp using Node.js and emscripten
Flavored with a real world example:
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Student at Ensimag
GDevelopOpen source game creation software
About me
@FlorianRival
florianrival.com
github.com/4ian
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Native app
Full JS (Node .js & Angular.js) powered app
WTF?
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
How GD works
Events are translated to JavaScript
Assets and data are compiled
Your awesome game
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Architecture of the webapp
GD core Interface(wxWidgets)
Extensions
C++
libGD.js
= The web app
front
bac
k
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Working with Emscripten
1) Expose your classes
3) Use it in JS!
2) Launch emscripten
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
1) Expose classesOriginal class (unmodified)
Embind(Wrapper code)
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
1) Expose functions
Original class (unmodified)
Embind (Wrapper code)
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
2) Launch emscripten
Compilation withClang
LLVM bitcode=> asm.js
output.js
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Using Emscripten generated code in Node
All objects binded with emscripten are in gd.*
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Using Emscripten generated code in Node
C++ classes JS objects (constructed with new)
Inheritance Working as expected
Types Converted transparently
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Working with emscripten
Objects created must be deleted
Beware of memory management
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Working with emscripten
Write tests!
Miscompilation?
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Working with emscripten
Huge files
Not a problem on a server
Compress for clients
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Working with emscripten
Can compile entire codebase without changes!
Compilation to asm.js, performance
are comparable to native app
No plugin, no intrusive changes, real compiler
It Just Works
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Emscripten: For which usage?
Porting part/core of a native app
Reusing a highly specialized library
GDevAppUnityGame engines
Physics libraries
Emulators
Image manipulation
https://github.com/kripken/emscriptenTons of examples
On emscripten webpages
Processing