renderInfo :: ProgramState -> IO ()
renderInfo p = do
  let h f g = if f `elem` p ^. flags then [p ^. g ^. to show] else []
      info = if Main.Info `elem` p ^. flags
             then (if ExtraInfo `elem` p ^. flags then p ^. extraInfo else [])
                  ++ h MouseInfo mouseState ++ h DragInfo dragState
                  ++ h ShiftInfo cameraShift
                  ++ if FocusPoint `elem` p ^. flags
                     then let n = p ^. cameraFocus . _2
                          in [show $ (p ^. cameraFocus . _1) !! n]
                     else []
                  ++ h Flags flags
             else []
      fps = if FramesPerSecond `elem` p ^. flags
            then map (++ " FPS") (h FramesPerSecond (timeState . _3))
            else []

  c <- get currentColor

  matrixMode $= Projection
  preservingMatrix $ do

    loadIdentity
    Size x y <- get windowSize
    ortho2D 0.0 (fromIntegral x) 0.0 (fromIntegral y)

    matrixMode $= Modelview 0
    preservingMatrix $ do
      color $ Color3 1.0 0.0 (0.0 :: GLfloat)
      let positions = [ Vertex2 22 (x' :: GLint) | x' <- [22, 44 .. ] ]
          r = zip positions . reverse $
              if FramesPerSecond `elem` p ^. flags
              then info ++ fps
              else info
      mapM_ (\(p', t) -> rasterPos p' >> renderString Helvetica18 t) r
      color c


-- | Draw a face of a cube. Used by 'drawCube'.
renderInfo :: ProgramState -> IO ()
renderInfo p = do
  let h f g = if f `elem` p ^. flags then [p ^. g ^. to show] else []
      info = if Main.Info `elem` p ^. flags
             then (if ExtraInfo `elem` p ^. flags then p ^. extraInfo else [])
                  ++ h MouseInfo mouseState ++ h DragInfo dragState
                  ++ h ShiftInfo cameraShift
                  ++ if FocusPoint `elem` p ^. flags
                     then let n = p ^. cameraFocus . _2
                          in [show $ (p ^. cameraFocus . _1) !! n]
                     else []
                  ++ h Flags flags
             else []
      fps = if FramesPerSecond `elem` p ^. flags
            then map (++ " FPS") (h FramesPerSecond (timeState . _3))
            else []

  c <- get currentColor

  matrixMode $= Projection
  preservingMatrix $ do

    loadIdentity
    Size x y <- get windowSize
    ortho2D 0.0 (fromIntegral x) 0.0 (fromIntegral y)

    matrixMode $= Modelview 0
    preservingMatrix $ do
      color $ Color3 1.0 0.0 (0.0 :: GLfloat)
      let positions = [ Vertex2 22 (x' :: GLint) | x' <- [22, 44 .. ] ]
          r = zip positions . reverse $
              if FramesPerSecond `elem` p ^. flags
              then info ++ fps
              else info
      mapM_ (\(p', t) -> rasterPos p' >> renderString Helvetica18 t) r
      color c


-- | Draw a face of a cube. Used by 'drawCube'.
renderInfo p = do
  let h f g = if f `elem` p ^. flags then [p ^. g ^. to show] else []
      info = if Main.Info `elem` p ^. flags
             then (if ExtraInfo `elem` p ^. flags then p ^. extraInfo else [])
                  ++ h MouseInfo mouseState ++ h DragInfo dragState
                  ++ h ShiftInfo cameraShift
                  ++ if FocusPoint `elem` p ^. flags
                     then let n = p ^. cameraFocus . _2
                          in [show $ (p ^. cameraFocus . _1) !! n]
                     else []
                  ++ h Flags flags
             else []
      fps = if FramesPerSecond `elem` p ^. flags
            then map (++ " FPS") (h FramesPerSecond (timeState . _3))
            else []

  c <- get currentColor

  matrixMode $= Projection
  preservingMatrix $ do

    loadIdentity
    Size x y <- get windowSize
    ortho2D 0.0 (fromIntegral x) 0.0 (fromIntegral y)

    matrixMode $= Modelview 0
    preservingMatrix $ do
      color $ Color3 1.0 0.0 (0.0 :: GLfloat)
      let positions = [ Vertex2 22 (x' :: GLint) | x' <- [22, 44 .. ] ]
          r = zip positions . reverse $
              if FramesPerSecond `elem` p ^. flags
              then info ++ fps
              else info
      mapM_ (\(p', t) -> rasterPos p' >> renderString Helvetica18 t) r
      color c


-- | Draw a face of a cube. Used by 'drawCube'.