Skip to content

[rcore][RGFW] Add fullscreen behaviour on size 0 window creation#5859

Merged
raysan5 merged 4 commits into
raysan5:masterfrom
keks137:rgfw_init_0
May 11, 2026
Merged

[rcore][RGFW] Add fullscreen behaviour on size 0 window creation#5859
raysan5 merged 4 commits into
raysan5:masterfrom
keks137:rgfw_init_0

Conversation

@keks137
Copy link
Copy Markdown
Contributor

@keks137 keks137 commented May 10, 2026

rcore_desktop_glfw has a nice feature of automatically creating a fullscreen window if you InitWindow(0,0,"title")
but on rgfw it instead just got stuck saying "failed to create drawable"
so I mostly just copied the logic, including the comments, from the glfw backend to handle this case
it does mean we now need to call RGFW_init ahead of time, to be able to get the primary monitor in the case of a size zero window

@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented May 10, 2026

@CrackedPixel Please, could you take a look to this PR? It surprises me that RGFW_init() was not called before... maybe it's not being tested against right RGFW version?

@raysan5 raysan5 changed the title [rcore_desktop_rgfw] port the rcore_desktop_glfw behaviour on size 0 window creation to rgfw [rcore][RGFW] Add fullscreen behaviour on size 0 window creation May 10, 2026
@keks137
Copy link
Copy Markdown
Contributor Author

keks137 commented May 10, 2026

@CrackedPixel Please, could you take a look to this PR? It surprises me that RGFW_init() was not called before... maybe it's not being tested against right RGFW version?

it usually automatically does it internally on createwindow for convenience
but we can't rely on that if we want the display size before that, it wouldn't be initialized yet and would segfault
so we need the explicit call

@CrackedPixel
Copy link
Copy Markdown
Contributor

I don't really like a lot of this PR but i will look at it today and compare to glfw and other platforms to see about a good solution

@CrackedPixel
Copy link
Copy Markdown
Contributor

@keks137 i made a PR for suggestions to your branch: keks137#1

@keks137
Copy link
Copy Markdown
Contributor Author

keks137 commented May 11, 2026

the changes seemed reasonable
I also just noticed something, that's what cbc5a1f is for
I missed that I was doing the FLAG_FULLSCREEN_MODE check twice, because I just copied glfw's version and worked from there, but the rgfw path already had a check above
they definitely should just be one check

@CrackedPixel
Copy link
Copy Markdown
Contributor

LGTM! nice work 😎

@keks137
Copy link
Copy Markdown
Contributor Author

keks137 commented May 11, 2026

actually one thing to note is that the return value of RGFW_init is rather weird:

from RGFW's source code:
/**!

  • @brief Initializes the RGFW library.
  • @return 0 on success, or a negative error code on failure.
  • @note This is automatically called when the first window is created.
    */

but if you look at the internal code, when you call it but it is already initialized it returns 1 - which is kind of weird but technically still correct within the api

where it gets truly weird is that it actually doesn't always return a negative number on error
for example in the wayland init there's this bit of code

if (_RGFW->compositor == NULL) {
		RGFW_sendDebugInfo(RGFW_typeError, RGFW_errWayland, "Can't find compositor.");
		return 1;
	}

this means we can't just check < 0, unlike the comment implies

for the purposes of raylib, breaking on multiple windows is technically not an issue, since that's not supported anyways, right?
#1989 (comment)

this might however still be an issue on
InitWindow
CloseWindow
and then
InitWindow
again
I'm not sure if that is something raylib supports
(one thing of note, this currently works in glfw, but segfaults in rgfw even without this specific issue, meaning I also can't check if this specifically actually doesn't work, but I'll assume it doesn't)

so maybe it would be better to ignore the return value entirely? that's what rgfw does whenever calling it internally
this return value is definitely a janky part of rgfw, maybe I should also open an issue there

@raysan5 raysan5 merged commit 9400199 into raysan5:master May 11, 2026
16 checks passed
@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented May 11, 2026

@keks137 thanks for the improvement and thanks @CrackedPixel for the review

@keks137
Copy link
Copy Markdown
Contributor Author

keks137 commented May 12, 2026

it seems we will be able to remove the RGFW_init call entirely in a future update of RGFW, the fact that we need it right now is a bug ColleagueRiley/RGFW#523 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants