mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-19 05:23:00 +01:00
Setup emscripten canvas.
This commit is contained in:
45
examples/common/entry_emscripten.cpp
Normal file
45
examples/common/entry_emscripten.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bx/bx.h>
|
||||
|
||||
#if BX_PLATFORM_EMSCRIPTEN
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <pthread.h>
|
||||
|
||||
extern int _main_(int _argc, char** _argv);
|
||||
|
||||
#include <setjmp.h>
|
||||
jmp_buf s_main;
|
||||
jmp_buf s_loop;
|
||||
|
||||
void emscripten_yield()
|
||||
{
|
||||
if (!setjmp(s_main) )
|
||||
{
|
||||
longjmp(s_loop, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (!setjmp(s_loop) )
|
||||
{
|
||||
longjmp(s_main, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int _argc, char** _argv)
|
||||
{
|
||||
if (!setjmp(s_loop) )
|
||||
{
|
||||
_main_(_argc, _argv);
|
||||
}
|
||||
|
||||
emscripten_set_main_loop(loop, 10, true);
|
||||
}
|
||||
|
||||
#endif // BX_PLATFORM_EMSCRIPTEN
|
||||
Reference in New Issue
Block a user