HighDPI issue on 0.10.2 / MacOS 10.13

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
fluffy
Prole
Posts: 7
Joined: Fri Feb 24, 2017 8:18 am

HighDPI issue on 0.10.2 / MacOS 10.13

Post by fluffy »

Hi, I'm using this bit of code to try to determine if the display is highdpi or not:

Code: Select all

    love.window.setMode(config.width, config.height, {
        resizable = true,
        fullscreen = config.fullscreen,
        vsync = config.vsync,
        highdpi = config.highdpi,
        minwidth = 480,
        minheight = 480
    })

    local _, _, flags = love.window.getMode()
    highdpi = flags.highdpi
    vsync = flags.vsync
where config is an object with configuration settings for the game; for the sake of this bug report assume it's set true.

On Windows, I correctly get a non-highdpi window, and flags.highdpi is false.

On macOS on a highDPI monitor, I correctly get a highdpi window, and flags.highdpi is true.

However, on macOS on a non-highDPI monitor (e.g. a 23" 1080p monitor), it gives me a non-highDPI window of the requested size, but the highdpi flag is still set true, so my game renders its UI fonts at twice the scale as it should.

Is there a better way to detect whether the screen supports highdpi? As far as I can tell, on macOS the flags.highdpi value is just what's passed in to the love.window.setMode call, regardless of whether it's getting an actual highdpi window.

As a hack I could look at love.graphics.getFullscreenModes and see if any of the modes' widths are greater than 2560 (since I don't know of any highdpi screens that are <= 2560 wide) but that seems inelegant. Unfortunately getFullscreenModes also doesn't tell me whether one is actually highdpi, it just gives the actual physical pixel width and height as far as I can tell.

Thanks!
fluffy
Prole
Posts: 7
Joined: Fri Feb 24, 2017 8:18 am

Re: HighDPI issue on 0.10.2 / MacOS 10.13

Post by fluffy »

After banging away on this a bit more I found love.window.getPixelScale() and that seems to work correctly. Using that function also has the nice benefit of cleaning up a bunch of my code anyway, so I'll just switch to using that!

The highdpi flag does still seem like a bug but love.window.getPixelScale() is a bit more precise in its meaning anyway, so that seems like a better solution overall (not to mention supports the distant future when the pixel scale is 3 or 4 or whatever).
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 28 guests