SDL_RENDERCOORDINATESTOWINDOW(3)
π SDL_RenderCoordinatesToWindow(3) π
okay bestie, listen up β this one lives in the SDL3 FUNCTIONS section of the manual, and it's literally the glow-up translator between render coordinates and window coordinates. β¨
πΈ NAME πΈ
SDL_RenderCoordinatesToWindow β get a point in window coordinates when you're handed a point in render coordinates.
π SYNOPSIS π
#include <SDL3/SDL_render.h>
bool SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
π¦ DESCRIPTION π¦
so here's the vibe: you give it a point that's chillin' in render coordinates, and it hands you back that same point but translated into window coordinates. it's giving personal translator fr fr. π
and the way it does that? it takes a whole bunch of states into account, no cap:
- the window dimensions. π
- the logical presentation settings (
SDL_SetRenderLogicalPresentation) - the scale (
SDL_SetRenderScale) - the viewport (
SDL_SetRenderViewport)
all four of those are lowkey in the mix, so don't be surprised when your point comes out somewhere else entirely. π
π FUNCTION PARAMETERS π
rendererβ the rendering context. your main character. π«Άxβ the x coordinate in render coordinates. πyβ the y coordinate in render coordinates. πwindow_xβ a pointer that gets filled with the x coordinate in window coordinates. πwindow_yβ a pointer that gets filled with the y coordinate in window coordinates. π
β¨ RETURN VALUE β¨
returns true on success, or false on failure. π and if it's a fail, bestie, call SDL_GetError() for more information. that's your receipts, always go get them.
π₯ THREAD SAFETY π₯
β οΈ this function should only be called on the main thread. no side-quests, no background threads, no exceptions. main thread only, periodt. π
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on something olderβ¦ yeah, that's a no from her. π
π SEE ALSO π
and that's the whole page, bestie, you ate that. π§ this one's brought to you by Simple Directmedia Layer, rockin' SDL 3.4.18 β mwah, take care of her, she's iconic. ππ
π¦ 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