-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Renderer texture clipping no longer respects scale (SDL_SetRenderScale
)
#11318
Comments
@icculus probably knows what's going on here. |
A little test to reproduce. #include <SDL3/SDL_main.h>
#include <SDL3/SDL.h>
int main(int argc, char** argv) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* win = SDL_CreateWindow(nullptr, 500, 500, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
SDL_Renderer* ren = SDL_CreateRenderer(win, nullptr);
SDL_SetRenderVSync(ren, 1);
SDL_SetRenderScale(ren, 0.5f, 0.5f);
bool running = true;
while(running) {
SDL_PumpEvents();
SDL_Event event;
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) == 1) {
switch (event.type) {
case SDL_EVENT_QUIT:
running = false;
break;
}
}
SDL_SetRenderDrawColor(ren, 0, 0, 0, SDL_ALPHA_OPAQUE);
SDL_RenderClear(ren);
SDL_SetRenderDrawColor(ren, 0, 255, 0, SDL_ALPHA_OPAQUE);
for(int r = 0; r < 500; r++)
SDL_RenderDebugText(ren, SDL_randf() * 1000, SDL_randf() * 1000, "*");
SDL_RenderPresent(ren);
SDL_Delay(100);
}
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
} |
Ah, yes. ef758d0 broke things for me. |
Okay, so what's happening here is two things:
I've got patches to change this, but before I push them, I just want to make sure we all agree that reducing the scope of SDL_SetRenderScale's influence is the correct and least-surprising thing to do. |
In SDL2 it affects everything because it was used to implement logical presentation, which virtualizes all your drawing. I think that's still the intention in case applications want to use it that way for their own custom logical presentation (and makes it possible for sdl2-compat to do the right thing).
That seems reasonable. The GPU should cull everything that's completely outside the viewport and I know we early out in the software blit code in that case. |
I'm not sure I agree about SDL_RenderSetScale, but we'll leave it as-is. The other fix is in now and makes this test program work as intended. |
It didn't take scale into account, and the backends would need to do clipping anyhow, so let the system figure that out for us at the lower level. Fixes libsdl-org#11318.
A recent change has caused textures to be cut-off from being drawn (clipped) when a scale is being set. Seems to affecting all renderers and platforms.
SDL_SetRenderScale(renderer, 0.5f, 0.5f)
will see textures only being draw on the top-left quarter of the window.The cause of this will probably be clear to whomever made a recent commit relating to texture clipping logic / viewport.
The text was updated successfully, but these errors were encountered: