entry_emscripten.cpp 960 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2011-2013 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #include <bx/bx.h>
  6. #if BX_PLATFORM_EMSCRIPTEN
  7. #include <emscripten/emscripten.h>
  8. #include <alloca.h>
  9. #include <setjmp.h>
  10. #include "entry.h"
  11. namespace entry
  12. {
  13. const Event* poll()
  14. {
  15. return NULL;
  16. }
  17. void release(const Event* _event)
  18. {
  19. }
  20. void setWindowSize(uint32_t _width, uint32_t _height)
  21. {
  22. }
  23. void toggleWindowFrame()
  24. {
  25. }
  26. void setMouseLock(bool _lock)
  27. {
  28. }
  29. } // namespace entry
  30. extern int _main_(int _argc, char** _argv);
  31. static jmp_buf s_main;
  32. static jmp_buf s_loop;
  33. void emscripten_yield()
  34. {
  35. if (!setjmp(s_main) )
  36. {
  37. longjmp(s_loop, 1);
  38. }
  39. }
  40. void loop()
  41. {
  42. if (!setjmp(s_loop) )
  43. {
  44. longjmp(s_main, 1);
  45. }
  46. }
  47. int main(int _argc, char** _argv)
  48. {
  49. if (!setjmp(s_loop) )
  50. {
  51. alloca(16<<10);
  52. _main_(_argc, _argv);
  53. }
  54. emscripten_set_main_loop(loop, 10, true);
  55. }
  56. #endif // BX_PLATFORM_EMSCRIPTEN