-
-
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] Incorrect resolution in Fullscreen mode #3099
Comments
Note that Still, there are plans to support that mode in a future. |
But there's a call to |
Here's a hacky way to fix the problem, running the ToggleFullscreen function one frame later. Please note that I have little idea of what I'm doing, but it works: typedef void (*funcPtr)(void); // define function pointer type
funcPtr* delayedFunctions = NULL; // list of functions to call next frame
int delayedFunctionCount = 0; // len(delayedFunctions)
// run all delayed functions
void runDelayed() {
for (int i = 0; i < delayedFunctionCount; i++) {
delayedFunctions[i](); // call the function
}
// free memory and reset function list
free(delayedFunctions);
delayedFunctions = NULL;
delayedFunctionCount = 0;
}
// add a function to the delayed function list
void addDelayedFunction(funcPtr function) {
delayedFunctions = realloc(delayedFunctions, (delayedFunctionCount + 1) * sizeof(funcPtr));
delayedFunctions[delayedFunctionCount] = function;
delayedFunctionCount++;
}
int main(void) {
InitWindow(1280, 720, "raylib window");
while (!WindowShouldClose()) {
runDelayed();
if (IsKeyPressed(KEY_F)) {
if (IsWindowFullscreen()) {
ToggleFullscreen();
SetWindowSize(screenWidth, screenHeight); // Keep the window size on the application side.
} else {
display_id = GetCurrentMonitor();
SetWindowSize(GetMonitorWidth(display_id), GetMonitorHeight(display_id));
addDelayedFunction(ToggleFullscreen);
}
}
}
} |
Yep, seems to work, I found a way to make it a bit more concise: // ...
if (IsKeyPressed(KEY_F11)) {
if (IsWindowFullscreen()) {
ToggleFullscreen();
SetWindowSize(width, height);
} else {
width = GetScreenWidth();
height = GetScreenHeight();
int monitor = GetCurrentMonitor();
SetWindowSize(GetMonitorWidth(monitor), GetMonitorHeight(monitor));
WaitTime(0.1);
PollInputEvents();
ToggleFullscreen();
}
}
// ... |
@SingularityT3 nice catch with WaitTime, I've a frame counter in my own code, but this is a far nicer solution. |
It seems this issue can be addressed with proposed solutions. |
Issue description
Resolution is incorrect after calling
ToggleFullscreen()
. I'm setting the window size to the monitor resolution before callingToggleFullscreen()
however the actual resolution happens to be the one which is set usingInitWindow()
or whatever the window size was after the last resize before going into fullscreen. I tried this on another computer running windows but I'm not able to reproduce it.After experimenting a bit I found that
CORE.Window.screen
hasn't been updated yet when insideToggleFullscreen()
andWindowSizeCallback()
is only run after going into fullscreen. Somehow this is not the case on my 2nd computer where the callback is run first. For now updatingCORE.Window.screen
inSetWindowSize()
seems to work but I'm not sure if this is the right fix.Environment
Arch Linux, KDE desktop environment, OpenGL 4.6, Intel HD Graphics 520
Code Example
The text was updated successfully, but these errors were encountered: