mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +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;
|
||||
|
||||
@@ -85,6 +85,11 @@ public:
|
||||
|
||||
double getPixelScale() const;
|
||||
|
||||
double toPixels(double x) const;
|
||||
void toPixels(double wx, double wy, double &px, double &py) const;
|
||||
double fromPixels(double x) const;
|
||||
void fromPixels(double px, double py, double &wx, double &wy) const;
|
||||
|
||||
const void *getHandle() const;
|
||||
|
||||
bool showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow);
|
||||
|
||||
Reference in New Issue
Block a user