sdlxRenderCoordinatesFromWindow function render
({double x, double y})?
sdlxRenderCoordinatesFromWindow(
- Pointer<
SdlRenderer> renderer, - double windowX,
- double windowY
Get a point in render coordinates when given a point in window coordinates.
This takes into account several states:
- The window dimensions.
- The logical presentation settings (SDL_SetRenderLogicalPresentation)
- The scale (SDL_SetRenderScale)
- The viewport (SDL_SetRenderViewport)
\param renderer the rendering context. \param window_x the x coordinate in window coordinates. \param window_y the y coordinate in window coordinates. \param x a pointer filled with the x coordinate in render coordinates. \param y a pointer filled with the y coordinate in render coordinates. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety This function should only be called on the main thread.
\since This function is available since SDL 3.2.0.
\sa SDL_SetRenderLogicalPresentation \sa SDL_SetRenderScale
extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y)
See also:
Implementation
({double x, double y})? sdlxRenderCoordinatesFromWindow(
Pointer<SdlRenderer> renderer,
double windowX,
double windowY,
) {
var x = 0.0;
var y = 0.0;
final xPointer = ffi.calloc<Float>();
final yPointer = ffi.calloc<Float>();
final result = sdlRenderCoordinatesFromWindow(
renderer,
windowX,
windowY,
xPointer,
yPointer,
);
if (result) {
x = xPointer.value;
y = yPointer.value;
}
xPointer.callocFree();
yPointer.callocFree();
if (!result) {
return null;
}
return (x: x, y: y);
}