Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit frame rate on wasm #1762

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/platform/wasm/Application-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static long getCurrentMillSecond() {
}

Application::Application()
: _animationInterval(1.0f/60.0f*1000.0f)
: _animationSpeed(60)
{
AX_ASSERT(! sm_pSharedApplication);
sm_pSharedApplication = this;
Expand Down Expand Up @@ -89,7 +89,8 @@ int Application::run()
// Retain glview to avoid glview being released in the while loop
glview->retain();

emscripten_set_main_loop(&mainLoopIter, 0, 1);
//emscripten_set_main_loop(&mainLoopIter, 0, 1);
emscripten_set_main_loop(&mainLoopIter, _animationSpeed, 1);
// TODO: ? does these cleanup really run?
/* Only work on Desktop
* Director::mainLoop is really one frame logic
Expand All @@ -108,7 +109,7 @@ int Application::run()

void Application::setAnimationInterval(float interval)
{
_animationInterval = interval*1000.0f;
_animationSpeed = 1.0f / interval;
}

void Application::setResourceRootPath(const std::string& rootResDir)
Expand Down
2 changes: 1 addition & 1 deletion core/platform/wasm/Application-wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Application : public ApplicationBase
*/
virtual Platform getTargetPlatform() override;
protected:
long _animationInterval; //micro second
long _animationSpeed; // micro second
std::string _resourceRootPath;

static Application * sm_pSharedApplication;
Expand Down
Loading