coordinatesFromWindow method

Point<double> coordinatesFromWindow(
  1. double windowX,
  2. 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.1.3.

\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)

Implementation

math.Point<double> coordinatesFromWindow(double windowX, double windowY) {
  var xPointer = calloc<Float>();
  var yPointer = calloc<Float>();
  sdlRenderCoordinatesFromWindow(this, windowX, windowY, xPointer, yPointer);
  var result = math.Point<double>(xPointer.value, yPointer.value);
  calloc.free(xPointer);
  calloc.free(yPointer);
  return result;
}