SFML community forums

Help => Graphics => Topic started by: degski on April 16, 2016, 08:01:42 am

Title: Pixel Drawing - 0- or 1-based? [Solved]
Post by: degski on April 16, 2016, 08:01:42 am
Hi All,

I'm seeing (Win10/SFML-2.3.2) the following behaviour, when drawing some pixels to a 800x800 window.

Top left corner:            0,     1
Top right corner:      799,     1
Bottom left corner:       0, 800
Bottom right corner: 799, 800

So it seems the y-component is 1-based, while the x-component is 0-based. I would not expect that. Is this expected behaviour, or a known factoid?
Title: Re: Pixel Drawing - 0- or 1-based?
Post by: TheGoldenFyre on April 16, 2016, 10:41:46 am
Having the same issue, but my theory is that Windows 10 draws over the top pixel of a program
Title: Re: Pixel Drawing - 0- or 1-based?
Post by: degski on April 16, 2016, 11:04:23 am
Having the same issue, but my theory is that Windows 10 draws over the top pixel of a program

Well, I don't think so, as pixel x,800 (on this 800x800 window) does get drawn, which I would not expect...
Title: Re: Pixel Drawing - 0- or 1-based?
Post by: Laurent on April 16, 2016, 01:51:44 pm
How exactly did you check that? If you draw single pixels (sf::Points primitive) don't forget that their coordinates must be the pixel center, not a corner (thus {0.5, 0.5} if you want to draw the top-left pixel).
Title: Re: Pixel Drawing - 0- or 1-based?
Post by: degski on April 16, 2016, 03:21:14 pm
How exactly did you check that? If you draw single pixels (sf::Points primitive) don't forget that their coordinates must be the pixel center, not a corner (thus {0.5, 0.5} if you want to draw the top-left pixel).

I checked that with integer coordinates... I did not forget (about the pixel centre), I didn't know...

Now (weapened with this new info) with 0.5 and 799.5 things work exactly as expected. Laurent, Merci Bocu!!!