| Summary: | SDL_Window + glContext -> SDL_SetWindowDisplayMode() fails to resize the WM window. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Yohann Ferreira <yohann.ferreira> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | CC: | bit.dangler |
| Version: | 2.0.0 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | The window doesn't resize leading to a gl context cut on top and on the right. | ||
This also applies on WinXP From looking at your init flags, your window has not been set with the full-screen flag and I suspect SDL_SetWindowDisplayMode() expects it to be in full-screen. If this suspicion is true then I will make it return a negative number and set a SDL error description. I will investigate it in more depth at the weekend. Hi bit.dangler, Thanks for your help on this! "I suspect SDL_SetWindowDisplayMode() expects it to be in full-screen." Is there any statement I could add in my code to test this suspicion? Also, you can find the sdl2 branch of my code here: https://github.com/Bertram25/ValyriaTear/tree/sdl2 You can find initial sdl window/context creation here: https://github.com/Bertram25/ValyriaTear/blob/sdl2/src/main.cpp#L487 And resolution change code here: https://github.com/Bertram25/ValyriaTear/blob/sdl2/src/engine/video/video.cpp#L375 I hope it'll help you. Best regards, (In reply to Yohann Ferreira from comment #3) > Hi bit.dangler, > > Thanks for your help on this! > > "I suspect SDL_SetWindowDisplayMode() expects it to be in full-screen." > Is there any statement I could add in my code to test this suspicion? Tweak your SDL window initialization code so it adds the additional SDL_WINDOW_FULLSCREEN flag. SDL_Window *sdl_window = SDL_CreateWindow(APPFULLNAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, // default size SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN); Confirm your resize logic works when you put it in fullscreen mode. I think you need to call SDL_SetWindowSize() instead of calling SDL_SetWindowDisplayMode if you want to change the window's size when not in full-screen. It should ideally return an error code when calling SDL_SetWindowDisplayMode when the window is not in full-screen. I will write a patch for this at the weekend. Hi again,
Ok, I'll make some tries and tell you.
> It should ideally return an error code when calling SDL_SetWindowDisplayMode
> when the window is not in full-screen. I will write a patch for this at the
> weekend.
Taken from the function description in the wiki:
"Use this function to set the display mode to use when a window is visible at fullscreen."
My bad, I guess my eyes (and brains) didn't get the fullscreen part. But then again, I'd say the function name is a bit misleading. (using the word "window" where you are handling fullscreen modes, but nevermind).
I'll also make tries using SDL_SetWindowSize in that case and see whether I can get something working.
Best regards!
Hi again, I confirm the SDL_SetWindowDisplayMode(sdl_window, &dsp_mode); is working in fullscreen mode for available display modes. I might be overrating it but I find the function name SetWindowDisplayMode() misleading as it doesn't clearly tell about handling fullscreen modes only. Just my two cents, though. bit.dangler might also still be willing to patch the function to return an error code when not in fullscreen. Thanks for you help, btw. :) I've also adjusted my code to use SDL_SetWindowSize() when not in fullscreen mode and it's working fine. :) Thanks for all the support. Best regards, Great. You're right it might be a little confusing. I just fixed it so SetWindowSize() will always affect the windowed size, even if you're currently fullscreen. Thanks Sam. :) I have one last request: Could you add this sentence (or something like) in the remarks section there: http://wiki.libsdl.org/SDL_SetWindowDisplayMode "To change the display mode when not in full screen, use SDL_SetWindowSize()" I bet this will make people like me realize one is not talking about actual windows here, but only fullscreen modes. I won't blame you if you don't but it costs nothing asking. ;) Best regards, You got it. :) Great! thanks. |
Created attachment 1331 [details] The window doesn't resize leading to a gl context cut on top and on the right. Hi :) When resizing the window using SDL_SetWindowDisplayMode(), the gl view port is correctly updated, but the window isn't. See attachment. code in a nutshell: // Window creation SDL_Window *sdl_window = SDL_CreateWindow(APPFULLNAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, // default size SDL_WINDOW_OPENGL); SDL_GLContext glcontext = SDL_GL_CreateContext(sdl_window); // ... // changing the resolution // After getting the closest possible available display mode SDL_SetWindowDisplayMode(sdl_window, &dsp_mode); -> See picture. Best regards,