Web: Move emscripten_set_main_loop from Game.c to Window_Web.c

This commit is contained in:
UnknownShadow200 2021-10-07 17:40:21 +11:00
parent 326c1445dd
commit d3a9477470
2 changed files with 7 additions and 8 deletions

View File

@ -36,9 +36,6 @@
#include "Protocol.h" #include "Protocol.h"
#include "Picking.h" #include "Picking.h"
#include "Animations.h" #include "Animations.h"
#ifdef CC_BUILD_WEB
#include <emscripten.h>
#endif
struct _GameData Game; struct _GameData Game;
cc_bool Game_UseCPEBlocks; cc_bool Game_UseCPEBlocks;
@ -623,7 +620,7 @@ void Game_Free(void* obj) {
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB
static cc_uint64 lastRender; static cc_uint64 lastRender;
static void Game_DoFrame(void) { void Game_DoFrame(void) {
cc_uint64 render; cc_uint64 render;
double time; double time;
Game_DoFrameBody() Game_DoFrameBody()
@ -631,10 +628,8 @@ static void Game_DoFrame(void) {
static void Game_RunLoop(void) { static void Game_RunLoop(void) {
lastRender = Stopwatch_Measure(); lastRender = Stopwatch_Measure();
emscripten_set_main_loop(Game_DoFrame, 0, false); /* Window_Web.c sets Game_DoFrame as the main loop callback function */
/* The Game_SetFpsLimit call back in Game_Load does nothing because no main loop yet */ /* (i.e. web browser is in charge of calling Game_DoFrame, not us) */
/* Now thats there's a main loop, Game_SetFpsLimit will actually do something */
Game_SetFpsLimit(Options_GetEnum(OPT_FPS_LIMIT, 0, FpsLimit_Names, FPS_LIMIT_COUNT));
} }
cc_bool Game_ShouldClose(void) { cc_bool Game_ShouldClose(void) {

View File

@ -350,8 +350,12 @@ extern int interop_IsAndroid(void);
extern int interop_IsIOS(void); extern int interop_IsIOS(void);
extern void interop_AddClipboardListeners(void); extern void interop_AddClipboardListeners(void);
extern void interop_ForceTouchPageLayout(void); extern void interop_ForceTouchPageLayout(void);
extern void Game_DoFrame(void);
void Window_Init(void) { void Window_Init(void) {
int is_ios, droid; int is_ios, droid;
emscripten_set_main_loop(Game_DoFrame, 0, false);
DisplayInfo.Width = GetScreenWidth(); DisplayInfo.Width = GetScreenWidth();
DisplayInfo.Height = GetScreenHeight(); DisplayInfo.Height = GetScreenHeight();
DisplayInfo.Depth = 24; DisplayInfo.Depth = 24;