Skip to content
New issue

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

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

Already on GitHub? # to your account

[HTML5] Fix blurry, low FPS and crash when zooming. #736

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

kan6868
Copy link
Contributor

@kan6868 kan6868 commented Oct 23, 2024

I have implemented this sample a few months ago, and it works well with various projects.

https://github.com/kan6868/s2d-html-template

  • Fixing blurry images:
    I enlarged the game content by double and then reduced the canvas size by half.
// keep ratio
float scaleX = (w * 2) / (float)fWidth;
float scaleY = (h * 2) / (float)fHeight;

//reduced canvas size
emscripten_set_element_css_size("canvas", w / 2, h / 2);
  • Fixing FPS flow issues:
    Based on this [Web] Frame Rate and UI fix #699

  • Fixing crashes when zooming:
    I realized that at certain screen sizes, the width or height values of the content would return 0. So, I reassigned them.

if (w == 0 || h == 0) 
{
	w = jsContextGetWindowWidth();
	h = jsContextGetWindowHeight();
}

@kan6868 kan6868 requested a review from Shchvova as a code owner October 23, 2024 06:25
@Shchvova Shchvova merged commit 84afee5 into coronalabs:master Oct 25, 2024
1 check passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants