coordinatesToWindow method

Point<double> coordinatesToWindow(
  1. double x,
  2. double y
)

Get a point in window coordinates when given a point in render 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 x the x coordinate in render coordinates. \param y the y coordinate in render coordinates. \param window_x a pointer filled with the x coordinate in window coordinates. \param window_y a pointer filled with the y coordinate in window 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.1.3.

\sa SDL_SetRenderLogicalPresentation \sa SDL_SetRenderScale \sa SDL_SetRenderViewport

extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y)

Implementation

math.Point<double> coordinatesToWindow(double x, double y) {
  var windowXPointer = calloc<Float>();
  var windowYPointer = calloc<Float>();
  sdlRenderCoordinatesToWindow(this, x, y, windowXPointer, windowYPointer);
  var result = math.Point<double>(windowXPointer.value, windowYPointer.value);
  calloc.free(windowXPointer);
  calloc.free(windowYPointer);
  return result;
}