libsdl-org / sdl2-compat

An SDL2 compatibility layer that uses SDL3 behind the scenes.
zlib License
80 stars 19 forks source link

Logical presentation should interfere with viewport and scaling state #226

Open icculus opened 1 month ago

icculus commented 1 month ago

As mentioned in https://github.com/libsdl-org/SDL/pull/10867#issuecomment-2375250237 ...

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 commented 1 week ago

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 commented 1 week ago

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

LiquidityC commented 1 week ago

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