-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[rcore][RGFW] bug fixes #4798
[rcore][RGFW] bug fixes #4798
Conversation
This is something similar that rcore_desktop_glfw.c does inside of WindowShouldClose() but no other function has those kind of checks. Other backends also don't have them. If this gets accepted, can we also port it to SDL, GLFW, etc? @raysan5 (also linking this to #4751 ) |
@ColleagueRiley @sleeptightAnsiC In raylib I tried to avoid/minimize this kind of checks, spreaded all around the code on all functions. Can it be checked only on InitWindow()? |
It should be possible to early return from Currently, there is a problem with raylib's initialization where, if a platform cannot provide Window and/or OpenGL context, the whole application will crash deep inside of rcore backend code, without any possibility to recover. I wanted to report/patch this, but then I noticed a similar PR #4164 where you rejected the fix @raysan5 Would it be fine, if I try to make another Issue and PR for this problem? (EDIT: I just reported the mentioned problem here: #4801 ) |
@sleeptightAnsiC Could it be just validated if the process (window+context creation) worked properly and just show a TraceLog() message showing the issue (like most raylib functions approach) if not initialized and then just set |
Replied under linked issue. |
If the window is not valid or is invalidated, there will be a confusing crash. This check is there to avoid the crash, but I agree that this is not how it should be done. Instead of the if-statement, there should be an assert on each function If you think there shouldn't be any asserts or checks, I will remove them. But they could be useful if something goes wrong. That other issue is not relevant for RGFW internally, RGFW fallbacks to a basic OpenGL context if it fails to load the accelerated context. The crash will still happen because RLGL does not use a fallback, but that could be easily added. As for |
src/platforms/rcore_desktop_rgfw.c
Outdated
@@ -303,8 +308,7 @@ void ToggleFullscreen(void) | |||
// Toggle borderless windowed mode | |||
void ToggleBorderlessWindowed(void) | |||
{ | |||
if (platform.window == NULL) | |||
return; | |||
if (platform.window == NULL) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to avoid adding that check to all the functions, if that check is required I think it should be implemented in RGFW library side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, they exist on the RGFW side as asserts.
@ColleagueRiley thanks for the review! |
platform.window
checkplatform.window
is valid firstRGFW_quit
properlyRGFW_windowMaximized
,RGFW_windowMinimized
andRGFW_windowRestored
eventsFLAG_WINDOW_UNFOCUSED
flag withRGFW_windowFocusOnShow