mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user