Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LÖVE 12 seems to incorrectly interpret the window size #2128

Open
Yolwoocle opened this issue Dec 18, 2024 · 7 comments
Open

LÖVE 12 seems to incorrectly interpret the window size #2128

Yolwoocle opened this issue Dec 18, 2024 · 7 comments
Labels
bug Something isn't working Linux Windows
Milestone

Comments

@Yolwoocle
Copy link

LÖVE 12 seems to incorrectly interpret the window size if it is resized right after launch, before love.load is even ran. The video below shows a minimal reproducible example, which is a game splash screen. Seems like the dimensions returned by love.graphics.getDimensions() are correct, but when objects are drawn onto the screen, they are squished and incorrectly sized. I'd like to note that this is not the case in LÖVE 11.5, the blue rectangle correctly takes up the whole screen.

Enregistrement.de.l.ecran.2024-12-18.104220_compr.mp4

Here's the code from the example above:

function love.conf(t)
    t.window.width = 100
    t.window.height = 100
end

-- Function that is run before the game has started loading
local function pre_init()
    -- Setting up the window
    love.window.setMode(100, 100, {
        resizable = true,
    })

    love.window.maximize()
    print("Current dimensions :", love.graphics.getDimensions())

    -- Splash screen that is supposed to take up the whole screen
    -- (Simple blue background with a white circle with a "Loading the game..." text)   
    local screen_w, screen_h = love.graphics.getDimensions()
    love.graphics.clear()
    
    love.graphics.setColor({0, 1, 1, 1})
    love.graphics.rectangle("fill", 0, 0, screen_w, screen_h)
    love.graphics.setColor({1, 1, 1, 1})
    love.graphics.circle("fill", 0, 0, 400, 400)
    love.graphics.setColor({0, 0, 0, 1})
    love.graphics.print("Loading the game...", 16, 16, 0, 16)

    love.graphics.present()
    love.graphics.setColor({1, 1, 1, 1})
end
pre_init()

-- Simulate loading the game
print("Loading...")
love.timer.sleep(1)
print("Finished loading.")

local a = 0

function love.update(dt)
    a = a + dt
end

function love.draw()
    love.graphics.circle("fill", 500 + math.cos(a) * 100, 500 + math.sin(a) * 100, 200)
end
@slime73
Copy link
Member

slime73 commented Dec 18, 2024

Which OS are you using, and how old is your copy of love 12?

If you're on Windows and use a screen with a non-100% display scale, high dpi support on Windows is currently slightly broken but significantly less broken compared to before this change from yesterday.

@Yolwoocle
Copy link
Author

I am on windows 11, and my copy of LÖVE 12 is from two days ago, so before this commit. My screen is indeed high DPI with 150% display scale. I'll pull your last commit later this evening and see if the issue is fixed.

@Yolwoocle
Copy link
Author

Seems like this didn't fit the issue, although getDimensions now return a smaller value.

Enregistrement.de.l.ecran.2024-12-18.180651.mp4

Not only that, my own pixel art game, which uses a low-res Canvas to render its sprites, now looks horrendous because of non-integer scaling, even when I specifically scale the concerned Canvas. Is this normal ? If it is, is there anything specific I need to do to fix this?

image

@slime73
Copy link
Member

slime73 commented Dec 18, 2024

my own pixel art game, which uses a low-res Canvas to render its sprites, now looks horrendous because of non-integer scaling, even when I specifically scale the concerned Canvas. Is this normal ? If it is, is there anything specific I need to do to fix this?

Set the dpiscale settings field in newCanvas to 1, or set t.usedpiscale = false in love.conf.

love 12 doesn't currently support low-dpi on Windows (or Android in both love 11 and love 12).

@slime73
Copy link
Member

slime73 commented Dec 18, 2024

That being said, you're always going to have to deal with non-integer scaling in some form if you have an arbitrary window size and you want a pixel art game to entirely fill the window rather than clamping to an integer scale factor.

@Yolwoocle
Copy link
Author

even when I specifically scale the concerned Canvas

I meant "when I specifically scale the concerned Canvas to an integer size"

That being said, you're always going to have to deal with non-integer scaling in some form if you have an arbitrary window size and you want a pixel art game to entirely fill the window rather than clamping to an integer scale factor.

Fair enough. My game already has an option to only scale the pixel art integer sizes; my point being that this didn't happen before love 12. 😅

Set the dpiscale settings field in newCanvas to 1, or set t.usedpiscale = false in love.conf.

love 12 doesn't currently support low-dpi on Windows (or Android in both love 11 and love 12).

This seemed to work. Slightly annoying that I now has to purposefully add in this in order for it to not look ugly, but no big deal 😅 Thanks!

@slime73
Copy link
Member

slime73 commented Dec 18, 2024

re this:

high dpi support on Windows is currently slightly broken but significantly less broken compared to before

love 12's high dpi support is still in progress (because SDL3 significantly changed how things work on Windows). We may introduce emulated low dpi support to make it match iOS/macOS/Wayland, we might tweak how high dpi situations behave, and/or we might make it more clear what you need to do in various situations.

That being said...

my point being that this didn't happen before love 12. 😅

It would do the same thing on Android in love 11 no matter what, and also on macOS/iOS on love 11 if you opt into high dpi there. On windows in love 11 it would look blurry no matter what, because love didn't support any high dpi at all there.

@slime73 slime73 added this to the 12.0 milestone Dec 24, 2024
@slime73 slime73 added bug Something isn't working Windows Linux labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Linux Windows
Projects
None yet
Development

No branches or pull requests

2 participants