mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Add 'usedpiscale' boolean (true by default) to love.window.setMode's settings table and love.conf's t.window table. Add love.window.getNativeDPIScale.
When usedpiscale=false, love will no longer automatically scale coordinates by the screen's DPI scale factor (so all coordinates will be in pixels), even when highdpi=true. love.window.getDPIScale will return 1, love.graphics.newCanvas will default to a dpi scale of 1 instead of the screen's dpi scale, etc. love.window.getNativeDPIScale() will return the screen's DPI scale as reported by the OS no matter what usedpiscale is set to.
This commit is contained in:
@@ -593,6 +593,7 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
||||
getPosition(settings.x, settings.y, settings.display);
|
||||
|
||||
settings.highdpi = (wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
settings.usedpiscale = newsettings.usedpiscale;
|
||||
|
||||
// Only minimize on focus loss if the window is in exclusive-fullscreen mode
|
||||
if (settings.fullscreen && settings.fstype == FULLSCREEN_EXCLUSIVE)
|
||||
@@ -1114,6 +1115,11 @@ void Window::DPIToWindowCoords(double *x, double *y) const
|
||||
}
|
||||
|
||||
double Window::getDPIScale() const
|
||||
{
|
||||
return settings.usedpiscale ? getNativeDPIScale() : 1.0;
|
||||
}
|
||||
|
||||
double Window::getNativeDPIScale() const
|
||||
{
|
||||
#ifdef LOVE_ANDROID
|
||||
return love::android::getScreenScale();
|
||||
|
||||
@@ -111,6 +111,7 @@ public:
|
||||
void DPIToWindowCoords(double *x, double *y) const override;
|
||||
|
||||
double getDPIScale() const override;
|
||||
double getNativeDPIScale() const override;
|
||||
|
||||
double toPixels(double x) const override;
|
||||
void toPixels(double wx, double wy, double &px, double &py) const override;
|
||||
|
||||
Reference in New Issue
Block a user