Created
November 23, 2015 03:01
-
-
Save ishiy1993/3c2025d7f911e9845baa to your computer and use it in GitHub Desktop.
HaskellでOpenGL(GLUT)を使って、長方形を描画する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
color (Color3 0 0 0 :: Color3 GLdouble) | |
renderPrimitive LineLoop $ mapM_ vertex2d [ | |
Vertex2 (-0.9) (-0.9) | |
, Vertex2 0.9 (-0.9) | |
, Vertex2 0.9 0.9 | |
, Vertex2 (-0.9) 0.9 | |
] | |
flush | |
where | |
vertex2d = vertex :: Vertex2 GLdouble -> IO () | |
main :: IO () | |
main = do | |
getArgsAndInitialize | |
initialDisplayMode $= [RGBAMode] | |
createWindow "Sample" | |
clearColor $= Color4 1 1 1 1 | |
displayCallback $= display | |
mainLoop | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment