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

Logical presentation should interfere with viewport and scaling state #226

Open
icculus opened this issue Sep 26, 2024 · 3 comments
Open

Comments

@icculus
Copy link
Collaborator

icculus commented Sep 26, 2024

As mentioned in libsdl-org/SDL#10867 (comment) ...

I probably need to do some further work to make the viewport/scale and logical presentation state mangle each other, but my guess is no one actually tried to use both at the same time in SDL2 because of this.

We would need this for perfect compatibility with SDL2, where logical presentation piggybacks on the scale and viewport--SDL3 now has them separated into separate states--but I also suspect that no app ever used both scaling/viewport and logical presentation at the same time, so I'm making a note in case we want to come back to this later.

@LiquidityC
Copy link

I recently ported my game to SDL3 after watching your Quake3 tutorial video (thansk for that). I can confirm that I'm getting some wonky behavior now. I was using viewports and renderer logical size in combination to allow for fullscreen or windowed mode (non re-sizable).
After porting to SDL3 it's visually obvious that the viewports and scaling don't sync up. The View scales but I only get the top left part of it rendered.

Here's an image in windowed mode:
image

And here's the clipping I get in fullscreen:
image

@icculus
Copy link
Collaborator Author

icculus commented Nov 5, 2024

Send me a link to the game's source (or binaries, if closed source) and I'll take a look.

@LiquidityC
Copy link

LiquidityC commented Nov 5, 2024

https://github.com/Oliveshark/breakhack/tree/feature/sdl3_port

SDL_SetRendererLogicalPresentation:
https://github.com/Oliveshark/breakhack/blob/c504b8b096d5cf6e5e64d784ae8db16884596c7e/src/main.c#L269

Toggle fullscreen:
https://github.com/Oliveshark/breakhack/blob/c504b8b096d5cf6e5e64d784ae8db16884596c7e/src/main.c#L779

Viewports:
https://github.com/Oliveshark/breakhack/blob/c504b8b096d5cf6e5e64d784ae8db16884596c7e/src/main.c#L287

(The offset variable here used to be how the render content was centered in SDL2. What the LETTERBOX mode attempts to do in SDL3 I'd assume)

Edit: Added some links to the interesting code

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

2 participants