OpenGL を使用して Haskell の 3D 空間でレンダリングするオブジェクトを取得しようとしています。ただし、Z 次元で形状をレンダリングする方法がわかりません。三角形のポイントの値を調整すると、レンダリングされなくなります。glEnable
(深度バッファを設定するのに欠けているものと同等のものはありますか?)
コードは次のとおりです(簡潔にするために編集されています):
initGL :: IO ()
initGL = do
shadeModel $= Smooth
clearDepth $= 1
depthFunc $= Just Lequal
hint PerspectiveCorrection $= Nicest
drawFrame :: WindowRefreshCallback
drawFrame = do
clear [ ColorBuffer, DepthBuffer ]
loadIdentity
renderPrimitive Triangles $ foldl1' (>>) $ map vertex
[ Vertex3 0 1 0 -- top
, Vertex3 1 (-1) 0 -- bottom right
, Vertex3 (-1) (-1) (0 :: GLdouble) -- bottom left
]
flush
main :: IO()
main = do
True <- initialize
True <- openWindow (Size 800 600) [] Window
... -- Set window title, set up callbacks
initGL
clearColor $= toGLColor (Color4 0 175 200 0)
doWhile (not <$> readIORef isClosed) $ drawFrame >> swapBuffers