RenderLogical And High Res Screenshot

On the web, you generally need pictures to be X resolution but it’ll look blurry on phones unless its X*pixel_density.

I was thinking about what’s the easiest way to take high res screenshots. I notice when pixel_density > 1 rendering still looks nice. I’m assuming it’s because SDL use float src and can draw more pixels than the windows width/height. So I thought if I use SDL_SetRenderLogicalPresentation and render to a 8k x 8k texture I can get a high res image. However it looks like actually fewer pixels? Because I used SDL_SetRenderLogicalPresentation? What else can I do?

I suspect my only choice is to multiple all my x’s, y’s, w’s and h’s by pixel density which for sure will work, but I wanted to know if there’s another option?

What do you mean it’s giving you fewer pixels? SDL_SetRenderLogicalPresentation() lets you pretend you always have, say, an 800x600 resolution screen regardless of window size or actual resolution.

Instead of messing with SDL_SetRenderLogicalPresentation(), I use SDL_SetRenderScale()

int outputWidth, outputHeight;
SDL_GetRenderOutputSize(renderer, &outputWidth, &outputHeight);
if(outputWidth != WINDOW_WIDTH | outputHeight != WINDOW_HEIGHT) {
	float scaleX = (float)outputWidth / (float)WINDOW_WIDTH;
	float scaleY = (float)outputHeight / (float)WINDOW_HEIGHT;
	SDL_SetRenderScale(renderer, scaleX, scaleY);
}
1 Like

IDK if it’s because I read the entire SDL3 api in 24hrs, or if I thought SDL_SetRenderLogicalPresentation covers the same functionality, but using SDL_SetRenderScale completely solved the problem. Thank you