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