main :: IO ()
main =
  do e <- init
     when (not e) $ putStrLn "Failed to init GLFW"
     windowHint $ WindowHint'ContextVersionMajor 3
     windowHint $ WindowHint'ContextVersionMinor 2
     windowHint $ WindowHint'OpenGLForwardCompat True
     windowHint $ WindowHint'OpenGLProfile OpenGLProfile'Core
     windowHint $ WindowHint'OpenGLDebugContext True
     win <- createWindow 1000 600 "NanoVG" Nothing Nothing
     case win of
       Nothing -> putStrLn "Failed to create window" >> terminate
       Just w ->
         do makeContextCurrent win
            glewInit
            glGetError
            c@(Context c') <- createGL3 (S.fromList [Antialias,StencilStrokes,Debug])
            -- error handling? who needs that anyway
            Just demoData <- runMaybeT $ loadDemoData c
            swapInterval 0
            setTime 0
            whileM_ (not <$> windowShouldClose w) $
              do Just t <- getTime
                 (mx,my) <- getCursorPos w
                 (width,height) <- getWindowSize w
                 (fbWidth,fbHeight) <- getFramebufferSize w
                 let pxRatio = fromIntegral fbWidth / fromIntegral width
                 glViewport 0 0 (fromIntegral fbWidth) (fromIntegral fbHeight)
                 glClearColor 0.3 0.3 0.32 1.0
                 glClear (GL_COLOR_BUFFER_BIT .|. GL_DEPTH_BUFFER_BIT .|. GL_STENCIL_BUFFER_BIT)
                 beginFrame c (fromIntegral width) (fromIntegral height) pxRatio
                 renderDemo c demoData mx my width height t
                 endFrame c
                 swapBuffers w
                 pollEvents
main :: IO ()
main =
  do e <- init
     when (not e) $ putStrLn "Failed to init GLFW"
     windowHint $ WindowHint'ContextVersionMajor 3
     windowHint $ WindowHint'ContextVersionMinor 2
     windowHint $ WindowHint'OpenGLForwardCompat True
     windowHint $ WindowHint'OpenGLProfile OpenGLProfile'Core
     windowHint $ WindowHint'OpenGLDebugContext True
     win <- createWindow 1000 600 "NanoVG" Nothing Nothing
     case win of
       Nothing -> putStrLn "Failed to create window" >> terminate
       Just w ->
         do makeContextCurrent win
            glewInit
            glGetError
            c@(Context c') <- createGL3 (S.fromList [Antialias,StencilStrokes,Debug])
            -- error handling? who needs that anyway
            Just demoData <- runMaybeT $ loadDemoData c
            swapInterval 0
            setTime 0
            whileM_ (not <$> windowShouldClose w) $
              do Just t <- getTime
                 (mx,my) <- getCursorPos w
                 (width,height) <- getWindowSize w
                 (fbWidth,fbHeight) <- getFramebufferSize w
                 let pxRatio = fromIntegral fbWidth / fromIntegral width
                 glViewport 0 0 (fromIntegral fbWidth) (fromIntegral fbHeight)
                 glClearColor 0.3 0.3 0.32 1.0
                 glClear (GL_COLOR_BUFFER_BIT .|. GL_DEPTH_BUFFER_BIT .|. GL_STENCIL_BUFFER_BIT)
                 beginFrame c (fromIntegral width) (fromIntegral height) pxRatio
                 renderDemo c demoData mx my width height t
                 endFrame c
                 swapBuffers w
                 pollEvents
main =
  do e <- init
     when (not e) $ putStrLn "Failed to init GLFW"
     windowHint $ WindowHint'ContextVersionMajor 3
     windowHint $ WindowHint'ContextVersionMinor 2
     windowHint $ WindowHint'OpenGLForwardCompat True
     windowHint $ WindowHint'OpenGLProfile OpenGLProfile'Core
     windowHint $ WindowHint'OpenGLDebugContext True
     win <- createWindow 1000 600 "NanoVG" Nothing Nothing
     case win of
       Nothing -> putStrLn "Failed to create window" >> terminate
       Just w ->
         do makeContextCurrent win
            glewInit
            glGetError
            c@(Context c') <- createGL3 (S.fromList [Antialias,StencilStrokes,Debug])
            -- error handling? who needs that anyway
            Just demoData <- runMaybeT $ loadDemoData c
            swapInterval 0
            setTime 0
            whileM_ (not <$> windowShouldClose w) $
              do Just t <- getTime
                 (mx,my) <- getCursorPos w
                 (width,height) <- getWindowSize w
                 (fbWidth,fbHeight) <- getFramebufferSize w
                 let pxRatio = fromIntegral fbWidth / fromIntegral width
                 glViewport 0 0 (fromIntegral fbWidth) (fromIntegral fbHeight)
                 glClearColor 0.3 0.3 0.32 1.0
                 glClear (GL_COLOR_BUFFER_BIT .|. GL_DEPTH_BUFFER_BIT .|. GL_STENCIL_BUFFER_BIT)
                 beginFrame c (fromIntegral width) (fromIntegral height) pxRatio
                 renderDemo c demoData mx my width height t
                 endFrame c
                 swapBuffers w
                 pollEvents