Skip to content
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

rpi video driver window mode isn't very useful #2185

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 2 comments
Closed

rpi video driver window mode isn't very useful #2185

SDLBugzilla opened this issue Feb 11, 2021 · 2 comments
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.4
Reported for operating system, platform: Linux, ARM

Comments on the original bug report:

On 2016-05-31 16:10:39 +0000, Logan McNaughton wrote:

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.

On 2016-05-31 16:13:53 +0000, Logan McNaughton wrote:

Created attachment 2474
Patch to fix problem

On 2016-06-01 14:23:12 +0000, Simon Hug wrote:

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.

On 2016-06-01 14:53:52 +0000, Logan McNaughton wrote:

(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.

On 2016-06-01 18:43:26 +0000, Simon Hug wrote:

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.

On 2016-06-01 19:42:33 +0000, Logan McNaughton wrote:

Created attachment 2477
Patch to SDL_hints.h

On 2016-06-01 19:43:01 +0000, Logan McNaughton wrote:

Created attachment 2478
New rpivideo.c patch with SDL hint

On 2016-06-01 19:43:23 +0000, Logan McNaughton wrote:

Created attachment 2479
New rpivideo patch with SDL hint

On 2016-06-01 19:44:37 +0000, Logan McNaughton wrote:

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.

On 2016-06-02 13:01:55 +0000, Simon Hug wrote:

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.

On 2016-06-02 14:16:04 +0000, Logan McNaughton wrote:

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.

On 2016-06-06 20:58:34 +0000, Philipp Wiesemann wrote:

The hint name should start with "SDL_HINT_" (e.g. SDL_HINT_RPI_STRETCH_WINDOW).

On 2016-06-06 21:32:45 +0000, Logan McNaughton wrote:

Would this patch be accepted if I changed the hint name? I don't own a mouse to test the cursor functionality.

On 2016-06-07 14:24:13 +0000, Logan McNaughton wrote:

Created attachment 2482
Patch to SDL_hints.h

On 2016-06-07 14:24:35 +0000, Logan McNaughton wrote:

Created attachment 2483
New rpivideo patch with SDL hint

On 2016-07-02 21:43:27 +0000, Philipp Wiesemann wrote:

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"

On 2016-07-07 19:05:06 +0000, Logan McNaughton wrote:

Created attachment 2528
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:

RetroPie/SDL-mirror#1

On 2017-02-20 21:33:27 +0000, Logan McNaughton wrote:

Is there anything else that needs to be done for this patch to be merged?

On 2017-02-21 05:30:33 +0000, Sam Lantinga wrote:

Out of curiosity, why do you have an aspect ratio hint? It seems like you should always respect the resolution set by the window?

On 2017-02-21 05:41:16 +0000, Logan McNaughton wrote:

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)

On 2017-02-21 06:26:15 +0000, Sam Lantinga wrote:

That's already handled by setting the scaling to 2 (stretch to fullscreen)

On 2017-02-21 15:03:57 +0000, Jools Wills wrote:

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

spurious/SDL-mirror@9d9af1f

and a c89 fix

RetroPie/SDL-mirror@6c42ad5

On 2017-02-21 15:10:07 +0000, Jools Wills wrote:

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 spurious/SDL-mirror@b02fe99 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)

On 2019-08-19 19:55:35 +0000, q3dev wrote:

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.

@icculus icculus removed the bug label Nov 30, 2021
@icculus
Copy link
Collaborator

icculus commented Nov 30, 2021

Let's look at this (and see if RetroPie still recommends it for people not on kmsdrm) for 2.0.20.

@icculus icculus added this to the 2.0.20 milestone Nov 30, 2021
@slouken
Copy link
Collaborator

slouken commented Mar 17, 2022

This patch looks good, but dispmanx has been deprecated on Raspberry Pi and doesn't work at all on the latest versions of Rasbian.

Closing this for now, but feel free to reopen it if there's a widely available use case.

@slouken slouken closed this as completed Mar 17, 2022
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

No branches or pull requests

3 participants