-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[core] FLAG_WINDOW_RESIZABLE
has no effect on PLATFORM_WEB
#3231
Comments
@Peter0x44 Sincerely, I can't remember why that code was there and what problem it tried to solve... but feel free to send a PR with the proposed changes. |
Was kinda curious of the backstory and did some digging into this so heres a quick gist. The 3 lines that set the canvas dimensions to itself was introduced with PR #1840 which introduced/finished up emscripten canvas resizing. To my knowledge, the foundation of this hasn't been changed since (aside from the occasional commenting and tweaking). A while after this, raysan commented the most of the code out for review (see 8f2d983) as games and examples would somewhat break when going into fullscreen, which should be where we are right now. |
I tried with my proposed patch, and didn't notice any issue upon going into fullscreen |
And just to make sure, you didn't notice any issue when pressing Fullscreen in |
@Peter0x44 did you try this case? |
@Peter0x44 tested the proposed change and it breaks the full-screen option, that was the reason it was commented. The issue should be fixed/reviewed in some other way but I remember it was not an easy topic, many side-cases and possibilities. |
@ubkp Please note that this issue could be very tricky, I remember dealing with it in the past and not being able to find a proper solution. The point is that window resizing vs scaling is application-dependant. For example:
Not to mention that fullscreeen switch will also launch the window resizing callback and the expectations for full-screen are completely different, actually there are multiple fullscreen strategies available. Oh, and just a last detail that I came up recently, the results seen on desktop-browser could completely differ from mobile-browser. That's another added problem to take care... |
@raysan5 Thank you very much for the guidance and references. I'll give it a week to see how far I can go. If I don't figure out anything by then, I'll withdraw. |
FLAG_WINDOW_RESIZABLE
has no effect on PLATFORM_WEB
FLAG_WINDOW_RESIZABLE
has no effect on PLATFORM_WEB
FLAG_WINDOW_RESIZABLE
has no effect on PLATFORM_WEB
@ubkp Any update on this issue? If no updates I will close it, I manage resizing as canvas CSS and it works for me. |
Could you elaborate on this CSS? I think it would be good reference to others |
@Peter0x44 You can check EDIT: Here an example: https://www.raylib.com/timeline.html |
@raysan5 shell.html doesn't do the same thing (acting like FLAG_WINDOW_RESIZABLE, I think) shellhtmlexample.mp4 |
@Peter0x44 True, you are right, Still, the proposed changes break that behaviour. I'll keep it open for future review. |
@raysan5 Really sorry for the late reply. I had a rough week that kept me away. |
@ubkp Sure, take your time, I'll keep this issue open until a proper solution can be found. |
Ok, so, the resize is working, well, kinda. 1. Regarding the resizing itself:We probably shouldn't use Luckly this is an easy fix with:
The logic being that due to the async nature of emscripten's callbacks, the 2. Regarding the resizing behavior:This resize works on the assumption that (when the user resizes) the user will want the canvas to fill the entire window size. Which could or could not be the case. IMHO, a
Edit: Case example at #3231 (comment). 3. Regarding the resizing scale:This resize doesn't change the scale, which, IMHO, is ok, since scaling currently is being left to the user (ref.: #3207 (comment)). 4. Regarding the standard fullscreen:The default (non-scaling) fullscreen is working.
Edit: The 5. Regarding the emscripten's fullscreen:The fullscreen issues appear to be related to the particular way
If that
Then flipping the
6. Regarding the shell.html scaling issue:With this resize enabled, when launching the program/game using the default Removing 7. Regarding leaving emscripten's fullscreen:If the user starts the program/game, then resizes it, then launches the fullscreen with This one I couldn't figure out yet, but, by the initial values, I'm assuming that emscripten is storing them somewhere and using it when leaving a fullscreen that started from 8. Moving forward:So, IMHO:
@raysan5 Could you please evaluate these? Edit 1: Changed itens 4 and D. |
Thanks for the detailed investigation! It's really summarizing everything nicely About point 2), I don't think any web-only (or any platform-specific) functions are exposed right now, and I don't think Ray will like that idea. I don't have a much better one though. |
@Peter0x44 Consider the case where the browser has a size of But that would actually be excellent to also have on |
@ubkp Wow! What a detailed review! Give me some time to evaluate it carefully! |
@ubkp Again, a very nice and detailed explanation! I'm still processing everything carefully. In any case, some notes:
@Peter0x44 Actually I think this is a good approach and yes, it can be useful outside web for windows that can not be scaled beyond a specific size (personally, I could think of some use cases on my tools). But in any case sounds a fair addition for function consistency.
@ubkp Oh, just saw your comment arriving to my same conclusion! 😄 I think the proposed improvements are great. My main concern is probably on
In any case, it's a really good improvement, I think some of my tools ( |
AFAIK, But I think the easiest solution would be that the developer just not enable |
@ubkp Is it possible to allow in any way the In any case, you can send a PR with the proposed improvements, undoubtely is the way to go... Despite having the browser automatically manage the scaling is really confortable in some situations... |
@raysan5 Yes, I believe the easiest way would be:
Full example (tested successfully here):
However, if you would like to keep But, on the other hand, removing @Peter0x44 Since you found the solution, would you like to send the PR? I can implement the |
So, my initial patch is okay?
|
Yes, your initial patch (#3231 (comment)). Just replace (on L6168-L6169):
By:
And, on your patch, instead of:
Please use:
Which addresses that item 1 from #3231 (comment). |
Submitted. Please give an "LGTM" so I know I haven't missed anything. |
No, this is not okay. I closed the PR, it doesn't work as expected. |
@Peter0x44 Just tested your PR sucessfully on What issue did you encounter? |
issueexample-2023-09-11_02.34.10.mp4I suspect something about the calculated size is incorrect. There is a some blank space at the bottom of the page, with minshell.html. Maybe it's the problem, I don't know. this is with firefox 117.0, on linux x11. |
I just realized this was actually an issue previously - I just didn't notice, since I had a white background. |
Okay, it seems it is the fault of minshell.html. Removing the |
@Peter0x44 The PR was fine, that "bottom white background" is just the |
Is there any way to eliminate the thin white line entirely? |
@Peter0x44 Sure, just add |
Thanks! I'm not much of a web dev so the solution wasn't obvious to me. |
Reopening because some of the proposed functionality has not been implemented yet. Waiting for |
@raysan5 I'm on it. I should have a PR ready fairly soon. 👍 By the way (just in case it got missed in the noise), the answer for you previous question: #3231 (comment) |
@ubkp thanks for the info, yeah, that could be a good solution. I still have to do some tests with my apps to see what works best. |
Tested and working as expected! Thanks! |
* Prettified a comment * fixed broken indentation caused by another commit. the commit renamed a bool to int and broke indentation: 233cf39 * Changed 0.001 and 0.00001 to EPSILON This commit is untested. I don't know what consequences this has. Since the commits that added these numbers were before epsilon was added, I have assumed that epsilon could replace them. * Prettied up indentation in a few places * removed spacing around *, standardizing it. * I may have gotten overboard with indentation * removed a few useless parenthesis * Added fortran-raylib * Fix examples/others/rlgl_standalone.c compilation issue (#3242) * Update BINDINGS.md * Ignore unused return value of GetCodepointNext in GetCodepointCount (#3241) * Ignore unused return value of GetCodepointNext in GetCodepointCount Removes the last warning from non-external libraries when compiling with the default build configuration on x64 Linux. * Remove unnecessary void cast in GetCodepointCount * Fix #3246 * Revert "Fix #3246" This reverts commit e4dcbd5. * Fix text_unicode.c example crashing (#3250) * Fix text_unicode.c example crashing * Adjust the text_unicode.c example crashing fix * tweaks * add build.zig options for individual modules (#3254) * Add `IsKeyPressedRepeat` (desktop only) (#3245) Since the key pressed are handle by comparing current vs previous state (ie frame), a special way is needed to handle key repeats. * Reviewed `IsKeyPressedRepeat()` #3248 * Update rcore.c (#3255) * Match CMakeOptions.txt options default values (#3258) * Fix SetClipboardText for web (#3257) * [Image] Validate that ImageDrawRectangleRec is drawing entirely inside the image (#3264) * Add a function to clone a sound and share data with another sound. * rename items based on feedback * PR Feedback, use custom unload for sound alias, not variant of normal sound unloading * sound_multi example * Validate that image rect drawing is inside the image so we don't overflow a buffer * remove files that should not have been added. * remove changes that should not have been * revert * adsfasdfsdfsdf * Add Vector3 Projecting and Rejection to Raymath (#3263) * Update raymath.h * formatting * [Feature] IsKey... safety checks and more (#3256) * [Feature] Add GetKeyRepeat * Update rcore.c * Simpler design, only one repeat per frame * Update config.h * Update rcore.c * Add KEYBOARD_KEYS_MASK * Update config.h * reversions * Update rcore.c * Update rcore.c * change docs * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Update raylib.h * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Update rcore.c * Fix bug where default shaders was not linking. (#3261) * Formating review * Add missing cmake options (#3267) * Fix CMake extraneous -lglfw (#3266) Closes #3265. The problem: LIBS_PRIVATE is a list of library names (used by pkg-config), but the shared library of the same name doesn't always exist. * Fix example/models/models_loading_gltf.c controls (#3268) * Fix example/models/models_loading_m3d.c controls (#3269) * Remove e from secondes (#3270) * Fix example/audio/audio_module_player.c help instructions and small bug (#3272) * Fix example/audio/audio_module_player.c help instructions and small bug * Update example/audio/audio_module_player.png screenshot * Use type name instead of valid specifier long long --> long long int * REVIEWED: `GetFileLength()`, added comment #3262 * Update examples/models/models_loading_gltf.png;m3d.png screenshots (#3273) * Remove a duplicated screenshot and add missing one (#3275) * Add examples/shaders/shaders_lightmap.c to Makefiles (#3276) * Fix examples/others/easings_testbed.c help instructions and small tweak (#3277) * Fix examples/shaders/shaders_texture_outline.c help instructions (#3278) * Fix examples/shapes/shapes_collision_area.c help instructions (#3279) * RENAMED: LoadFont*() parameter names for consistency and coherence * Fix uninitialized thread-locals in stbi #3282 (#3283) * REVIEWED: Added `SetTextLineSpacing()` to multiline examples * REVIEWED: Data size type consistency between functions #3168 * Some tweaks * Use internal default allocators, instead of user-exposed ones * Added rudimentary SVG support. (#2738) * Added rudimentary SVG support. Added 2 functions ImageLoadSvg and ImageLoadSvgWithSize. * Added an example on how to use ImageLoadSvgWithSize and adjusted Makefiles accordingly. * Added actual correct example file. * Reviewed the code to keep the raylib coding conventions in mind. Moved the LoadImageSvg() code into LoadImage() guarded by SUPPORT_FILEFORMAT_SVG. Renamed LoadImageSvgWithSize() to LoadImageSvg(). Added a LoadImageSvgFromString() function to parse the loaded SVG into an actual image. This does the bulk of the work. * Fixed typo. --------- Co-authored-by: Ray <[email protected]> * REVIEWED: `LoadImageSvg()` * REVIEWED: `LoadImageSvg()` * Add SUPPORT_FILEFORMAT_SVG to cmake (#3284) * Fix examples/textures/textures_fog_of_war.c help instructions (#3285) * Fix examples/textures/textures_image_rotate.c help instructions (#3286) * Update rtextures.c * Fix #3247 * Update config.h * Fix #3293 * Disable UBSAN in zig builds. (#3292) Zig debug builds automatically enable ubsan. As the fix for #1891 had to be reverted, debug builds using zig will crash like so: ``` Illegal instruction at address 0x3237d2 raylib/src/rlgl.h:3690:91: 0x3237d2 in rlDrawVertexArrayElements (/home/rcorre/src/raylib-zig-template/raylib/src/rcore.c) glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)buffer + offset); ``` This disables UBSAN when using zig to build raylib. * Update README.md (#3290) specially -> especially * Update cmake SUPPORT_FILEFORMAT_SVG default value (#3291) * Mouse offset and scaling must be considered also on web! * Update rcore.c * Update Makefile : clean raygui.c & physac.c (#3296) * Remove PLATFORM_RPI (#3232) * Remove PLATFORM_RPI * remove build artifacts --------- Co-authored-by: MichaelFiber <[email protected]> Co-authored-by: Ray <[email protected]> * Review to avoid UBSAN complaining #1891 * added raylib-raku to bindings (#3299) * examples: core: adds 2D camera two player split screen (#3298) * Reviewed examples for consistency * Update rtext.c * Some code restructuring for input functions, consistency review * Remove unneeded #if (#3301) Co-authored-by: MichaelFiber <[email protected]> * Revert "Disable UBSAN in zig builds. (#3292)" (#3303) This reverts commit a316f9e. Issue #1891 was fixed again, so this is no longer needed. * rtextures: Fix ImageDraw() source clipping when drawing beyond top left (#3306) * REVIEWED: `TextToPascal()` issue when first char is uppercase * Implement FLAG_WINDOW_RESIZABLE for web (#3305) Fixes #3231 * Update BINDINGS.md (#3307) Fix Kaylib binding. Reroute to a new repository. Binding renamed. * Update webassembly.yml * Add claw-raylib to BINDINGS.md (#3310) * Add SetWindowMaxSize for desktop and web (#3309) * Add SetWindowMaxSize for desktop and web * Remove SizeInt and respective adjustments * Update rtextures.c * Reviewed parameters for consistency * Rename windowM* to screenM* (#3312) * Update BINDINGS.md (#3317) Update TurboRaylib bindings * Update rmodels.c * Update BINDINGS.md with vaiorabbit/raylib-bindings (#3318) * fixed spelling mistake * put back parenthesis * reverted major allignment changes * reverted parser output changes * reverted one more indentation change --------- Co-authored-by: Brian-E <[email protected]> Co-authored-by: Ray <[email protected]> Co-authored-by: ubkp <[email protected]> Co-authored-by: ashn <[email protected]> Co-authored-by: actondev (Christos) <[email protected]> Co-authored-by: vitopigno <[email protected]> Co-authored-by: Asdqwe <[email protected]> Co-authored-by: Jeffery Myers <[email protected]> Co-authored-by: Ethan Simpson <[email protected]> Co-authored-by: Nickolas McDonald <[email protected]> Co-authored-by: Branimir Ričko <[email protected]> Co-authored-by: iacore <[email protected]> Co-authored-by: Ethan Conneely <[email protected]> Co-authored-by: Johannes Barthelmes <[email protected]> Co-authored-by: bXi <[email protected]> Co-authored-by: Ryan Roden-Corrent <[email protected]> Co-authored-by: Ikko Eltociear Ashimine <[email protected]> Co-authored-by: SuperUserNameMan <[email protected]> Co-authored-by: MichaelFiber <[email protected]> Co-authored-by: MichaelFiber <[email protected]> Co-authored-by: Dan Vu <[email protected]> Co-authored-by: Gabriel dos Santos Sanches <[email protected]> Co-authored-by: Rob Loach <[email protected]> Co-authored-by: Peter0x44 <[email protected]> Co-authored-by: Kenta <[email protected]> Co-authored-by: bohonghuang <[email protected]> Co-authored-by: turborium <[email protected]> Co-authored-by: Wilson Silva <[email protected]>
Issue description
FLAG_WINDOW_RESIZABLE has no effect on PLATFORM_WEB
Issue Screenshot
Code Example
compile with:
emcc resize_example.c -I path/to/raylib/src ./libraylib.a -s USE_GLFW=3 -s WASM=1 --shell-file minshell.html -o resize_example.html
The following 3 lines seem to do nothing:
raylib/src/rcore.c
Lines 6176 to 6178 in db55bed
They set the height of the canvas... to the existing height/width of the canvas, so they are unchanged
The callback they are in is unused, anyway
the following patch seems to fix the issue:
It uncomments the lines that set the callback, and sets the canvas width/height to the windowInnerWidth and windowInnerHeight
The result:
resizer.mp4
The text was updated successfully, but these errors were encountered: