coronalabs / corona

Solar2D Game Engine main repository (ex Corona SDK)
https://solar2d.com/
MIT License
2.54k stars 273 forks source link

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

Closed kan6868 closed 4 weeks ago

kan6868 commented 1 month ago

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

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

//reduced canvas size emscripten_set_element_css_size("canvas", w / 2, h / 2);

- Fixing FPS flow issues: 
Based on this #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.

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