RenderTarget.MapPixelToCoords Method

SFML.Net

RenderTargetMapPixelToCoords Method
Overload List
  Name Description
Public method MapPixelToCoords(Vector2i)
Convert a point from target coordinates to world coordinates, using the current view This function is an overload of the MapPixelToCoords function that implicitely uses the current view. It is equivalent to: target.MapPixelToCoords(point, target.GetView());
Public method MapPixelToCoords(Vector2i, View)
Convert a point from target coordinates to world coordinates This function finds the 2D position that matches the given pixel of the render-target. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel. Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world -- if the view is translated by (140, 25). For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor. This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.
Top
See Also