0

I'm writing a cross-platform application which draws a 2d image read from PNG file using OpenGL. My program works on Linux, Windows and Mac OS X. In Linux and Windows it works fine, but in Mac OS X the image is not drawn pixel-perfect. The image looks a bit blurry and when moving the image with mouse the image gets slightly different blurring artifacts depending on which area of the OpenGL viewport the image is drawn at, i.e. with which transformation matrix.

I use Mavericks and clang++ 5.1.

I don't do any half-pixel shifting as it is not needed with OpenGL for pixel-perfect rendering.

I was thinking that it might be some difference in floating point computations between these 3 platforms, I tried -frounding-math and -ffloat-store compiler flags, but none of them helped.

Did anyone else encountered that problem on Mac OS X?

igagis
  • 1,959
  • 1
  • 17
  • 27
  • The answer to your question will probably be "yes". Did that help? – PlasmaHH Aug 24 '14 at 19:18
  • 1
    You should definitifely show the relevant code parts. "I don't do any half-pixel shifting as it is not needed with OpenGL for pixel-perfect rendering." is quite generic. There are lots of ways to get a not pixel-perfect output. – derhass Aug 24 '14 at 19:35
  • igagis also your assumption that you don't need pixel shifting is not entirely correct. OpenGL textures have their pixel centers on fractional coordinatas (not x + 0.5 though), the exact coordinate remapping depends on the texture size. If you want to address pixels directly you can either make the coordinate adjustment or use texelFetch in the fragment shader (which takes integer pixel index coordinates), but doesn't offer any filtering at all. – datenwolf Aug 25 '14 at 09:02

1 Answers1

0

I found what was the reason.

I was moving the image with mouse, setting image's coordinates to mouse coordinates. In Cocoa mouse coordinates arriving to mouseMoved: method of NSView have fractional part for some reason. So, the solution was to round mouse coordinates before using them to set coordiantes of image in GL viewport.

igagis
  • 1,959
  • 1
  • 17
  • 27