Davidobot / love.js

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.5)
MIT License
605 stars 27 forks source link

love.resize is not called when changing the size of the love.js canvas #59

Open apicici opened 2 years ago

apicici commented 2 years ago

I just ported my game to love.js (it was a bit tricky because I'm also using fmod), and I noticed that love.resize is not called when the love.js canvas is resized (including when going to fullscreen mode). I have t.window.resizable = true in conf.lua and I tried on chromium and firefox on Linux.

Is this the expected behaviour? This seems to be a similar issue to #33 (I also get blurry fullscreen because love.resize is not called), but my understanding by reading the comments there is that setting t.window.resizable = true should lead to love.resize being called when changing the canvas size.

Davidobot commented 2 years ago

This should have been solved but see this https://github.com/Davidobot/love.js/issues/16#issuecomment-818620056

apicici commented 2 years ago

I saw that when I was searching earlier, but I'm not sure how that can help. All of the things listed in that comment are already implemented in the index.html file, but the love.resize callback is never called (not even once). Is there a way to trigger love.resize from javascript?

alexjgriffith commented 2 years ago

To call lua (e.g. love.resize) from JS and vice versa, check out the Love.js API player, referenced in #26

https://github.com/MrcSnm/Love.js-Api-Player

apicici commented 2 years ago

To call lua (e.g. love.resize) from JS and vice versa, check out the Love.js API player, referenced in #26

https://github.com/MrcSnm/Love.js-Api-Player

I've been using that to make fmod work by calling JavaScript from lua, but it's not clear to me by reading the instructions how to call lua functions from JavaScript.

alexjgriffith commented 2 years ago

You can use JS.newRequest from within love to call a JavaScript function polling the size of the canvas and call love.resize when there is a change. Make sure you call JS.retrieveData in the update loop. Note, you will also have to run globalizeFS.js on the love.js file to get FS working in this fork. There are instructions in the README.

This is a bit of a hack. We could see about implementing stdin stdout for the module, which would let you interact with a repl.

apicici commented 2 years ago

I'll try that, thanks!