Skip to content

Instantly share code, notes, and snippets.

@doivosevic
Created March 24, 2016 19:43
Show Gist options
  • Save doivosevic/a06531e1ef924d9072cf to your computer and use it in GitHub Desktop.
Save doivosevic/a06531e1ef924d9072cf to your computer and use it in GitHub Desktop.
asd
module Main where
import Control.Monad
import Data.Maybe
--import qualified Irg.Matrix as M
--import qualified Irg.Vector as V
import qualified Graphics.GL.Compatibility33 as GL
import qualified Graphics.UI.GLUT as GLUT
import Graphics.UI.GLUT (($=))
withWindow :: (GLUT.Window -> IO ()) -> IO ()
withWindow act = do
_ <- GLUT.initialize "irg" []
GLUT.initialWindowPosition $= GLUT.Position 100 100
GLUT.initialWindowSize $= GLUT.Size 400 500
GLUT.initialDisplayMode $= [GLUT.RGBAMode]
GLUT.actionOnWindowClose $= GLUT.Exit
w <- GLUT.createWindow "irg"
GLUT.displayCallback $= GLUT.flush
GLUT.keyboardCallback $= Just (\_ _ -> release w)
print "Start end"
--GLUT.mainLoop
GLUT.get GLUT.glVersion >>= print
act w
where release w = do
print "Exit start"
GLUT.destroyWindow w
GLUT.mainLoopEvent
GLUT.exit
print "Exit end"
simulate :: IO ()
simulate = withWindow $ \_ -> do
let loop = do
--print "Loop start"
GL.glClearColor 0 0 0 1
GL.glClear GL.GL_COLOR_BUFFER_BIT
cw <- GLUT.get GLUT.currentWindow
GL.glColor3f 1 0 0
GL.glBegin GL.GL_POINTS
GL.glVertex2i 50 50
sequence_ [ GL.glVertex2i i i | i <- [0..100] ]
GL.glEnd
GL.glColor3f 1 1 0
GL.glBegin GL.GL_LINE
GL.glVertex2i 10 0
GL.glVertex2i 100 0
GL.glEnd
GLUT.flush
GLUT.swapBuffers
GLUT.mainLoopEvent
when (isJust cw) loop
loop
main :: IO()
main = do
putStrLn "Hi!"
--simulate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment