[Solved] Screen and window dimensions

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
IsawU
Prole
Posts: 16
Joined: Sat May 02, 2015 6:26 pm

[Solved] Screen and window dimensions

Post by IsawU »

The wiki states that top left corner in at ( 0; 0 ), however I need to use the following code to light up two pixels, one in the top left corner and the other in the bottom right corner.

Code: Select all

love.graphics.points(0, 1, love.graphics.getWidth()-1, love.graphics.getHeight())
This happens in fullscreen ('desktop' fullscreentype).
The same happens in windowed, where additionally the visible area is +1 px right than the drawable area.

Canvas behaves a little differently. Pixel positions are ( 0; 0 ) top left and bottom right is ( Canvas:getWidth()-1; Canvas:getHeight()-1 ) as expected. Yet I have noticed a thing that if you clear the canvas to a color of your choice, the colored area will be +1 px right and +1 px down than the area I can use to draw my two pixels, but I don't really mind this.

Later I checked the actual width of Canvas on a screenshot and the width is actually the same as I defined, which got me even more confused. It seems as if the Canvas was right size, yet the coordinates 0 to 49 (which is 50 possible values) are not as wide as 50 pixels.

The thing I wonder is if that's same for everybody or the screen/window dimensions/origins are kind of variable and what numbers should I use to draw in the corners then.
I belive that the logical origin for rotations is always ( 0; 0 ) though, it's just the graphics.

Thanks, plus I included my test source if you want to try.
Attachments
test.love
(1.82 KiB) Downloaded 111 times
Last edited by IsawU on Sun Jul 23, 2017 9:47 am, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Screen and window dimensions

Post by bartbes »

I think what you're seeing is that in OpenGL the "pixels" of the screen are actually between coordinates. If you draw your point at (0.5, 0.5), it should look like a single pixel.
User avatar
IsawU
Prole
Posts: 16
Joined: Sat May 02, 2015 6:26 pm

Re: Screen and window dimensions

Post by IsawU »

bartbes wrote: Sun Jul 23, 2017 9:33 am I think what you're seeing is that in OpenGL the "pixels" of the screen are actually between coordinates. If you draw your point at (0.5, 0.5), it should look like a single pixel.
Indeed. What you say is 100% correct and drawing pixels at ( 0.5; 0.5 ) and ( width - 0.5; height - 0.5 ) produces pixels in corners.

Thanks for this clarification, it makes sense to have pixels at 0.5.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Google [Bot] and 8 guests