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