2 #include "sdl-application.h"
5 #include <dali/public-api/dali-core.h>
9 // main loop function called by emscripten/browser
10 extern void emscripten_set_main_loop(void (*func)(), int fps, int simulate_infinite_loop);
18 extern void RenderFinished();
23 Dali::SdlApplication *app = NULL;
25 void EmscriptenMouseEvent(double x, double y, int downUpMotion)
27 DALI_ASSERT_ALWAYS(app);
31 app->SendTouchEvent(x,y, downUpMotion);
40 // This wasnt working prior to emscripten v1.25
42 // But it only gives event inside the gl window.
43 // When dragging (for rotation etc) we want the drag/rotate to continue outside the window
45 // So we'll disable this handling for now
48 while (SDL_PollEvent(&event))
55 void EmscriptenUpdateOnce()
57 DALI_ASSERT_ALWAYS(app);
61 void EmscriptenRenderOnce()
63 DALI_ASSERT_ALWAYS(app);
68 // 'Module' here should be 'dali' with emcc switch -s EXPORT_NAME="dali"
69 // but on upgrading to emscripten 1.34.2 it's broken.
70 int _x = EM_ASM_INT_V({ return Module.canvas.width; });
71 int _y = EM_ASM_INT_V({ return Module.canvas.height; });
86 app->SetSurfaceWidth(w, h);
91 EmscriptenUpdateOnce();
95 Dali::Internal::Emscripten::RenderFinished();
98 int main(int argc, char *argv[])
100 using namespace Dali;
102 // need to reference everything as emscripten/llvm will cut it all out so put a Actor here
105 app = new SdlApplication( 0, 0, SdlApplication::DEFAULT_HORIZONTAL_DPI, SdlApplication::DEFAULT_VERTICAL_DPI );
107 emscripten_set_main_loop(EmscriptenRenderOnce, 0, 1);