Added love.window.toPixels(x [, y]) and love.window.fromPixels(x [, y]), for easier conversion between window-space and pixel-space values when highdpi mode is enabled on a retina display in OS X (and in the iOS and Android ports of LÖVE.)

This commit is contained in:
Alex Szpakowski
2014-09-14 15:58:37 -03:00
parent f972c9923f
commit 00944c5f5d
7 changed files with 96 additions and 20 deletions
+24
View File
@@ -682,6 +682,30 @@ double Window::getPixelScale() const
return scale;
}
double Window::toPixels(double x) const
{
return x * getPixelScale();
}
void Window::toPixels(double wx, double wy, double &px, double &py) const
{
double scale = getPixelScale();
px = wx * scale;
py = wy * scale;
}
double Window::fromPixels(double x) const
{
return x / getPixelScale();
}
void Window::fromPixels(double px, double py, double &wx, double &wy) const
{
double scale = getPixelScale();
wx = px / scale;
wy = py / scale;
}
const void *Window::getHandle() const
{
return window;