Window one pixel higher than expected

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
User avatar
Foppy
Prole
Posts: 5
Joined: Mon Aug 28, 2017 8:50 pm
Contact:

Window one pixel higher than expected

Post by Foppy » Thu Sep 21, 2017 11:01 pm

In the game I am writing a window mode is set like this:

Code: Select all

love.window.setMode(1024,768)
It seems that the window is one pixel higher than expected. Since the top row is at y = 0, I thought the bottom row should be y = 767. But drawing a horizontal line at y = 767 still leaves a line of pixels below it. (Which can be filled by drawing a line at y = 768.) It can be worked around in the game but I wondered if I am missing something or that this is a known thing. :)

User avatar
raidho36
Party member
Posts: 1685
Joined: Mon Jun 17, 2013 12:00 pm

Re: Window one pixel higher than expected

Post by raidho36 » Thu Sep 21, 2017 11:08 pm

I've actually measured the window size and it's exactly what it was set to. You're probably misunderstanding the render coordinates.

User avatar
Foppy
Prole
Posts: 5
Joined: Mon Aug 28, 2017 8:50 pm
Contact:

Re: Window one pixel higher than expected

Post by Foppy » Thu Sep 21, 2017 11:36 pm

Thank you, you are correct in that the window is of the requested height. I didn't think of checking it like that!

The problem or my confusion then seems to be in how the line is drawn using love.graphics.line().

The following still leaves a row of empty pixels below the line:

Code: Select all

love.graphics.setLineStyle("rough")
love.graphics.setLineWidth(1)
love.graphics.setColor(255,0,0)
love.graphics.line(0,767,1024,767)

grump
Party member
Posts: 365
Joined: Sat Jul 22, 2017 7:43 pm

Re: Window one pixel higher than expected

Post by grump » Thu Sep 21, 2017 11:40 pm

It's exactly what it should be for me too (Linux, LÖVE 10.2).

In theory, coordinates for points and lines should be offset by 0.5 for correct rendering, because you're supposed to specify the pixel centers. As far as I understand, a line from (0, 767) to (1023, 767) should be drawn as

Code: Select all

love.graphics.line(0.5, 767.5, 1023.5, 767.5)
But ONLY points and lines, and line rectangles; not text, filled rectangles, images or other primitives(?); I'm not entirely sure though; it's a little bit confusing, tbh.

User avatar
Foppy
Prole
Posts: 5
Joined: Mon Aug 28, 2017 8:50 pm
Contact:

Re: Window one pixel higher than expected

Post by Foppy » Thu Sep 21, 2017 11:45 pm

you're supposed to specify the pixel centers
This explains it! I ran into this because I am writing a pseudo 3d racing game which consists mostly of horizontal lines and saw a few unexpected empty lines. Thanks for your help!

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 11 guests