On OSX (with 2560 x 1600 native resolution), Gloss displays everything at zoom-factor 2x. Giving a window size of 300 x 300 to the display function creates a window of 600 x 600. All content in that window is also twice as big (in each dimension), regardless of whether drawn with Gloss or loaded as a sprite (I'm using Juicy for that). Scaling the content down does not give the same clean result as when displayed in the actual native resolution. Is there a way to make Gloss render in full native resolution?
I'm still new to Gloss and hope I haven't missed anything obvious.
Here is the code...
module Main where
import Graphics.Gloss
import Graphics.Gloss.Juicy
import Codec.Picture
main :: IO ()
main = loadJuicy "someimg.png" >>= maybe ( print "Nope" ) displayImg
displayImg :: Picture -> IO ()
displayImg p = display ( InWindow "Image" ( 300, 300 ) ( 100, 100 ) ) white ( pictures [ p, translate 32 32 $ circleSolid 4 ] )
... and the corresponding render:
Update: This seems to be a general issue with OpenGL and retina displays (actually the way OSX pixels are calculated internally). Since, as I understand, Gloss doesn't really allow low-level access my guess is that this is not fixable.
Update 2: This seems to be a particular issue with GLUT as the underlying backend for Gloss. Rebuilding Gloss enabling GLFW and disabling GLUT should fix the issue.
Gloss can be used with native resolution under OSX with hdpi-display when the default window management backend GLUT is exchanged for GLFW. To do this rebuild Gloss with the appropriate flags:
cabal install -f -GLUT -f GLFW
(Note: With GLFW I could not use some modules in Gloss anymore, e.g. Gloss.Data.Picture or maybe more importantly Graphics.Gloss.Juicy. Using only Graphics.Gloss.Rendering works though. Related to the resolution: make sure to draw your pictures in the size of the framebuffer, not the window size as those may differ.)