| Summary: | rpi video driver window mode isn't very useful | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Logan McNaughton <logan> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | buzz, chli.hug, ioq3, philipp.wiesemann |
| Version: | 2.0.4 | ||
| Hardware: | ARM | ||
| OS: | Linux | ||
| Attachments: |
Patch to fix problem
Patch to SDL_hints.h New rpivideo.c patch with SDL hint New rpivideo patch with SDL hint Patch to SDL_hints.h New rpivideo patch with SDL hint Update patch |
||
Created attachment 2474 [details]
Patch to fix problem
Why settle for one option if we could have both? The SDL hint system offers a great way to solve this issue. Shouldn't mupen64plus check if the window size isn't what was requested? SDL makes no guarantees here. The application should have options on how to scale its contents. (In reply to Simon Hug from comment #2) > Why settle for one option if we could have both? The SDL hint system offers > a great way to solve this issue. > > Shouldn't mupen64plus check if the window size isn't what was requested? SDL > makes no guarantees here. The application should have options on how to > scale its contents. Even if mupen64plus realized that the window size is wrong, what is it going to do about it? I'm sure mupen64plus could scale the contents, but that requires work from the GPU, this patch accomplishes the scaling at basically no cost to the GPU. Anyway, I don't know anything about SDL hints, but the way it works right now is not very useful. If someone requests a window, it just makes it full screen and sends it back to the user, at least with this patch they get the resolution they wanted. Perhaps. But forcing a stretch to fullscreen with whatever filter dispmanx is using might not be useful to someone else. Especially if the aspect ratios don't match. Have a look at the SDL_hints.h header. These hints can be used to change the behavior of SDL with a change of an environment variable. You can add another one for this case and use SDL_GetHint in the RPI_CreateWindow function to decide if SDL should do it the current or your way. Created attachment 2477 [details]
Patch to SDL_hints.h
Created attachment 2478 [details]
New rpivideo.c patch with SDL hint
Created attachment 2479 [details]
New rpivideo patch with SDL hint
Fair enough, I've added patches for SDL_hints.h and SDL_rpivideo.c to use the hint SDL_RPI_STRETCH_WINDOW. Tested and working on my Raspberry Pi 3 in both modes. I tested it as well and noticed that the stretching breaks the position of the software cursor which the SDL Raspberry Pi driver puts on screen. It obviously doesn't know about the scaling. hm ok I don't know about that, I don't use a cursor, I am using a fullscreen OpenGL application controlled by a joypad. The hint name should start with "SDL_HINT_" (e.g. SDL_HINT_RPI_STRETCH_WINDOW). Would this patch be accepted if I changed the hint name? I don't own a mouse to test the cursor functionality. Created attachment 2482 [details]
Patch to SDL_hints.h
Created attachment 2483 [details]
New rpivideo patch with SDL hint
The value of the hint should not contain the "SDL_HINT_" (as documented at the top of SDL_hints.h :). #define SDL_HINT_RPI_STRETCH_WINDOW "SDL_RPI_STRETCH_WINDOW" Created attachment 2528 [details] Update patch This is a more robust version of this patch written by gizmo98 on GitHub. I have attached the patch as pull from GitHub, you can see the discussion that went along with this here: https://github.com/RetroPie/SDL-mirror/pull/1 Is there anything else that needs to be done for this patch to be merged? Out of curiosity, why do you have an aspect ratio hint? It seems like you should always respect the resolution set by the window? I believe it would be to take a 4:3 window and stretch it to 16:9 fullscreen (instead of having black bars on the side) That's already handled by setting the scaling to 2 (stretch to fullscreen) The aspect ratio hint is useful for fine tuning aspect ratio - eg for emulators for systems where the original pixels were not quite square etc. The referenced patch is out of date btw - we also now include https://github.com/spurious/SDL-mirror/commit/9d9af1f5943bda8fccd4463b6085d45c8325d359 and a c89 fix https://github.com/RetroPie/SDL-mirror/commit/6c42ad55b293893ac472106248148dc706acf10c I can provide an updated patch including everything if needed - if not we will just continue to maintain it our own fork - which we need anyway as we need to have this revert https://github.com/spurious/SDL-mirror/commit/b02fe999cc9a04bf3b663327d1a82d0cbfa75817 as ps3 controllers are broken without it in Emulation station and other sdl2 apps. (This is mentioned in another ticket - https://bugzilla.libsdl.org/show_bug.cgi?id=3277) Hello, I've been using this patch in my game and it works well. It's been included in RetroPie for 2+ years now. Would it be possible to get an updated patch and include this in SDL? Thanks everyone for working on this. |
in RPI_CreateWindow (video/raspberry/SDL_rpivideo.c), it does this: /* Windows have one size for now */ window->w = display->desktop_mode.w; window->h = display->desktop_mode.h; It overwrites the SDL window size with the size of the display. Basically window mode is disabled. I'll give you an example of why this is not helpful: My rpi runs at a resolution of 640x480. If I run mupen64plus (n64 emulator) with --windowed --resolution 320x240, it just uses 1/4 of the screen, because SDL is overwriting the resolution back to 640x480, and mupen64plus is rendering at 320x240. I created this patch: https://github.com/loganmc10/game_launcher/blob/master/sdl_patch.patch This uses dispmanx to stretch the image. So if your display is 640x480, and you create an SDL Window that is 320x240, it will stretch that 320x240 image to fit 640x480. This is useful. Since the rpi doesn't really support windows, this is more useful than overwriting the window size like it does now.