SDL_SETRENDERLOGICALPRESENTATION(3)
π SDL_SetRenderLogicalPresentation π
okay bestie, welcome to the SDL3 functions manual β this one is SDL_SetRenderLogicalPresentation(3) and it's literally about giving your renderer a vibe of its own dimensions. no cap. let's go π¦
β¨ NAME β¨
SDL_SetRenderLogicalPresentation β Set a device-independent resolution and presentation mode for rendering. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_render.h>
bool SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode);
π DESCRIPTION π
so like, this function sets the width and height of the logical rendering output. the renderer will act as if the current render target is always the requested dimensions, and it'll scale to the actual resolution as necessary. it's giving "main character decides their own size, reality adjusts." β¨
this can be useful for games that expect a fixed size but would like to scale the output to whatever is available, regardless of how a user resizes a window, or if the display is high DPI. fr fr, super handy. π
logical presentation can be used with both render target textures and the renderer's window β the state is unique to each render target, and this function sets the state for the current render target. so it might be useful to draw to a texture that matches the window dimensions with logical presentation enabled, and then draw that texture across the entire window with logical presentation disabled. but be careful not to render both with logical presentation enabled, however, as this could produce double-letterboxing, etc. π that's the cursed timeline, we don't want it.
double-letterboxing alert!! render both with logical presentation enabled and you get double-letterboxing, etc. pls don't. π
you can disable logical coordinates by setting the mode to SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel resolution of the render target. it is safe to toggle logical presentation during the rendering of a frame: perhaps most of the rendering is done to specific dimensions but to make fonts look sharp, the app turns off logical presentation while drawing text, for example. see? versatile. iconique. π«Ά
you can convert coordinates in an event into rendering coordinates using SDL_ConvertEventToRenderCoordinates(). iykyk. π
π§ FUNCTION PARAMETERS π§
rendererβ the rendering context. your lil guy. your renderer bestie. πwβ the width of the logical resolution.hβ the height of the logical resolution.modeβ the presentation mode used.
β RETURN VALUE β
returns true on success or false on failure; call SDL_GetError() for more information. so if it flops, go read the error, bestie, it's telling you something. π
π₯ THREAD SAFETY π₯
this function should only be called on the main thread. no side-quest threads for this one, periodt. π
π AVAILABILITY π
this function is available since SDL 3.2.0. vintage-ish. iconic. β¨
π¦ SEE ALSO π¦
SDL_ConvertEventToRenderCoordinates(3)SDL_GetRenderLogicalPresentation(3)SDL_GetRenderLogicalPresentationRect(3)
and that's the whole page, bestie!! this cutie came to you from Simple Directmedia Layer, version SDL 3.4.18, and it's the SDL_SetRenderLogicalPresentation(3) page. go forth and set your logical presentation, you absolute legend ππΈπ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms