SDL_RenderCo...tesFromWindow(3)
β¨ SDL_RenderCoordinatesFromWindow β¨
okay bestie so we're in the SDL3 FUNCTIONS section of the manual and today's main character is SDL_RenderCoordinatesFromWindow π
she's the one who tells you where a point on your window actually lands in render-land. no cap.
πΈ NAME πΈ
SDL_RenderCoordinatesFromWindow β get a point in render coordinates when given a point in window coordinates. fr fr, that's the whole job. π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_render.h>
bool SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
π DESCRIPTION π
so you hand her a point in window coordinates and she hands you back that same point translated into render coordinates. it's giving translator, it's giving glow-up for your numbers β¨
and the way she does it?? she takes several states into account, literally all of them:
- the window dimensions π
- the logical presentation settings (that's
SDL_SetRenderLogicalPresentation) - the scale (that's
SDL_SetRenderScale) - the viewport (that's
SDL_SetRenderViewport)
so like. don't think you can just vibe and skip those. she's accounting for all of it, periodt.
π FUNCTION PARAMETERS π
rendererβ the rendering context. your girl. the whole operation runs through her πwindow_xβ the x coordinate in window coordinates. the input, the origin story π«Άwindow_yβ the y coordinate in window coordinates. the other half of the input πxβ a pointer filled with the x coordinate in render coordinates. she writes it for you, you don't lift a finger β¨yβ a pointer filled with the y coordinate in render coordinates. same deal, filled right up π
π RETURN VALUE π
returns true on success or false on failure π and if it's a fail bestie, do NOT just sit there β call SDL_GetError() for more information. that's where the tea is β
π₯ THREAD SAFETY π₯
this function should only be called on the main thread. no side-quests on other threads, i'm so serious π
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on something older... not her problem, upgrade bestie π§
π SEE ALSO π
and that's the page!! π written under the Simple Directmedia Layer name, version SDL 3.4.18 β mwah, slay, go render something gorgeous πβ¨π¦
π¦ 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