4

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:

Screenshot of the 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.

4

1 回答 1

2

当默认的窗口管理后端 GLUT 被替换为 GLFW 时,Gloss 可以在 OSX 下使用 hdpi-display 与本机分辨率一起使用。为此,请使用适当的标志重建 Gloss:

cabal install -f -GLUT -f GLFW

(注意:使用 GLFW,我无法再使用 Gloss 中的某些模块,例如 Gloss.Data.Picture 或更重要的是 Graphics.Gloss.Juicy。但仅使用 Graphics.Gloss.Rendering 有效。与分辨率相关:确保绘制您的图片在帧缓冲区的大小中,而不是窗口大小,因为它们可能会有所不同。)

于 2019-06-09T09:42:28.147 回答