I’m trying to switch a section of my app to fullscreen.
On Flash target, we can use stage.fullScreenSourceRect.
But this is not available/implemented on HTML5 target
So I’m trying to find a way to achieve the same result.
The __displayMatrix should affect how the Stage renders. It works (at least) on OpenGL, and could be respected elsewhere. Further support for stage.displayMode as well as fullScreenSourceRect would ultimately change what __displayMatrix value we use.
Please share if you make any progress or have questions
Thank you for pointing out the relevant code.
So, I’m able to alter the rendering by changing stageWidth & stageHeight.
However, when switching to fullscreen, it doesn’t affect the container (e.g. window) so the stage is rendered in a small portion, instead of taking all space.
I have tried to use stage.window.resize() instead, but for some reason it makes the stage rendered at a wrong offset and the container still has the original dimensions so I get empty space all around the stage
It should display a 200x200 red square, with a 100x100 blue square inside.
When clicking on it, it will switch to fullscreen, but the whole sprite is currently visible (instead of displaying only a part of it).
Changing web browser tab back & forth does refresh the stage and then shows the left/top section of the sprite (which is correct), but at the wrong position.
Try and change the displayMatrix, instead of the stage width and height. For example, you could scale up the matrix by 2, to keep the same screen resolution, but display all the stage content at double the size. We might not be able to change the display resolution to match the desired rectangle, but we should be able to scale the content so that that is all that’s visible
Yes, I tried to force a scale on __displayMatrix : it makes the stage zoomed (as expected) but it stays inside its “container”, so the content is cropped.
Using fullScreenSourceRect on Flash doesn’t seem to affect stageWidth/stageHeight properties.
As you mentionned, I think we need something to change the logical “resolution” to make it work like Flash.
The black letterboxing is indeed due to the offsetY=100 applied to __displayMatrix in this case.
In fact, whatever I change in __displayMatrix, it will still stay inside the “container”, so the left/right white borders are always there.
Maybe we should patch the canvas element dimensions to let the browser do the job, since the default rule is width=100%; height=100% ?
I made more tests, and figured out I could achieve the result I wanted by changing the height from 600 to 400 in the generated index.html : lime.embed ("MyApp, "openfl-content", 800, 400, { parameters: {} });
Now the question is : how can I change the window size properties during runtime ?
I have tried openfl.Lib.current.stage.window.resize(), but it didn’t work.