Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Pixel Drawing - 0- or 1-based? [Solved]  (Read 2951 times)

0 Members and 1 Guest are viewing this topic.

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Pixel Drawing - 0- or 1-based? [Solved]
« 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?
« Last Edit: April 16, 2016, 03:26:34 pm by degski »

TheGoldenFyre

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Pixel Drawing - 0- or 1-based?
« Reply #1 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

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Pixel Drawing - 0- or 1-based?
« Reply #2 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...
« Last Edit: April 16, 2016, 11:07:31 am by degski »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Pixel Drawing - 0- or 1-based?
« Reply #3 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).
Laurent Gomila - SFML developer

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Pixel Drawing - 0- or 1-based?
« Reply #4 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!!!

 

anything