@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
GDevelop
Open 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
C++ JS
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
C++ JS
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
How GD works
Eventsaretranslated
toJavaScript
Assetsanddataare
compiled
Your awesome game
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Architecture of the webapp
GDcore
Interface
(wxWidgets)
Extensions
C++
libGD.js
= The web app
frontbac
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 classes
Original 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 with
Clang
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
GDevAppUnity
Game engines
Physics libraries
Emulators
Image manipulation
https://github.com/kripken/emscripten
Tons of examples
On emscripten webpages
Processing
@GDevApp http://gdevapp.com Node.js Paris – Fevrier 2015
Thanks!
@GDevApp
facebook.com/GDevApp
https://gdevapp.com
https://gdevapp.com
Node.js Paris – Fevrier 2015@GDevApp http://gdevapp.com

From a native app to a webapp using Node.js and emscripten