Skip to content

Instantly share code, notes, and snippets.

@doivosevic
Created March 24, 2016 21:42
Show Gist options
  • Save doivosevic/e1f0172223b8fc62b41d to your computer and use it in GitHub Desktop.
Save doivosevic/e1f0172223b8fc62b41d to your computer and use it in GitHub Desktop.
ye
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 (($=))
reshapeCallback :: GLUT.Size -> IO ()
reshapeCallback (GLUT.Size newWidth newHeight) = do
GL.glViewport 0 0 newWidth newHeight
GL.glMatrixMode GL.GL_PROJECTION
GL.glLoadIdentity
GLUT.ortho2D 0 (fromIntegral newWidth) 0 (fromIntegral newHeight)
GL.glMatrixMode GL.GL_MODELVIEW
GL.glLoadIdentity
GL.glClearColor 1 1 1 0
GL.glClear GL.GL_COLOR_BUFFER_BIT
GL.glPointSize 1.0
GL.glColor3f 0 0 0
keyboardCallback :: Char -> GLUT.Position -> GLUT.Window -> IO ()
keyboardCallback key (GLUT.Position x y) win = do
print key >> print x >> print y
case key of
'\r' -> GLUT.destroyWindow win >> GLUT.mainLoopEvent >> GLUT.exit >> print "Exit end"
'r' -> GL.glColor3f 1 0 0
'g' -> GL.glColor3f 0 1 0
'b' -> GL.glColor3f 0 0 1
'k' -> GL.glColor3f 0 0 0
_ -> return ()
GL.glRecti (x-10) (y-10) (x+10) (y+10)
GL.glFlush
withWindow :: IO ()
withWindow = do
_ <- GLUT.initialize "irg" []
GLUT.initialWindowPosition $= GLUT.Position 100 100
GLUT.initialWindowSize $= GLUT.Size 600 400
GLUT.initialDisplayMode $= [GLUT.RGBAMode]
GLUT.actionOnWindowClose $= GLUT.Exit
w <- GLUT.createWindow "irg"
GLUT.reshapeCallback $= Just reshapeCallback
GLUT.displayCallback $= GLUT.flush
GLUT.keyboardCallback $= Just (\char position -> keyboardCallback char position w)
print "Start end"
GLUT.get GLUT.initState >>= print
GLUT.get GLUT.glVersion >>= print
GLUT.mainLoop
--act w
main :: IO()
main = putStrLn "Hi!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment