diff options
author | Kostadin Damyanov <maxmight@gmail.com> | 2015-10-13 05:01:54 +0300 |
---|---|---|
committer | Kostadin Damyanov <maxmight@gmail.com> | 2015-10-13 05:01:54 +0300 |
commit | 29caf2bb5be061cd1ab014cf938f2c71d0bd2663 (patch) | |
tree | 859a0c3d2805198672c1e22d4780c3eb68f55a57 /platform/javascript/javascript_main.cpp | |
parent | c5f574b914b3cb11d97ae616df4a0bced45bb17c (diff) | |
parent | 79e5ced7e668fa53567ac6aaf5a26393cea6c9a2 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'platform/javascript/javascript_main.cpp')
-rw-r--r-- | platform/javascript/javascript_main.cpp | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 5be6c5b647..fb87dc848e 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -31,6 +31,9 @@ #include "main/main.h" #include "io/resource_loader.h" #include "os/keyboard.h" +#include "emscripten.h" +#include <string.h> + OS_JavaScript *os=NULL; static void _gfx_init(void *ud,bool gl2,int w, int h,bool fs) { @@ -196,15 +199,39 @@ static void _gfx_idle() { glutPostRedisplay(); } +int start_step=0; + static void _godot_draw(void) { - os->main_loop_iterate(); + if (start_step==1) { + start_step=2; + Main::start(); + os->main_loop_begin(); + } + + if (start_step==2) { + os->main_loop_iterate(); + } + glutSwapBuffers(); } + + +extern "C" { + +void main_after_fs_sync(int value) { + + start_step=1; + printf("FS SYNCHED!\n"); +} + +} + int main(int argc, char *argv[]) { - /* Initialize the window */ + + /* Initialize the window */ printf("let it go!\n"); glutInit(&argc, argv); os = new OS_JavaScript(_gfx_init,NULL,NULL,NULL,NULL); @@ -218,7 +245,7 @@ int main(int argc, char *argv[]) { #endif ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility - Main::start(); + glutSpecialUpFunc(_glut_skey_up); glutSpecialFunc(_glut_skey_down); @@ -236,10 +263,32 @@ int main(int argc, char *argv[]) { // glutReshapeFunc(gears_reshape); glutDisplayFunc(_godot_draw); //glutSpecialFunc(gears_special); - os->main_loop_begin(); + + + + //mount persistent filesystem + EM_ASM( + FS.mkdir('/userfs'); + FS.mount(IDBFS, {}, '/userfs'); + + + + // sync from persisted state into memory and then + // run the 'test' function + FS.syncfs(true, function (err) { + assert(!err); + console.log("done syncinc!"); + _after_sync_cb = Module.cwrap('main_after_fs_sync', 'void',['number']); + _after_sync_cb(0); + + }); + + ); glutMainLoop(); + + return 0; } |