GLUT-2.7.0.12: A binding for the OpenGL Utility Toolkit

Copyright | (c) Sven Panne 2002-2013
License | BSD3
Maintainer | Sven Panne <svenpanne@gmail.com>
Stability | stable
Portability | portable
Safe Haskell | None
Language | Haskell2010

Graphics.UI.GLUT.Begin

Contents

- Handling events
- Controlling the behaviour when windows are closed

Description

After a GLUT program has done initial setup such as creating windows and menus, GLUT programs enter the GLUT event processing loop by calling `mainLoop` or handle events iteratively with `mainLoopEvent`.

Synopsis

- mainLoop :: MonadIO m => m ()
- mainLoopEvent :: MonadIO m => m ()
- leaveMainLoop :: MonadIO m => m ()
- data ActionOnWindowClose
  - = Exit
  - | MainLoopReturns
  - | ContinueExecution
- actionOnWindowClose :: StateVar ActionOnWindowClose

# Handling events

mainLoop :: MonadIO m => m () Source #

Enter the GLUT event processing loop; it will call as necessary any callbacks that have been registered. This routine should be called at most once in a GLUT program.

mainLoopEvent :: MonadIO m => m () Source #

(freeglut only) Process one iteration's worth of events in its event loop. This allows the application to control its own event loop and still use the GLUT package.

leaveMainLoop :: MonadIO m => m () Source #

(freeglut only) Stop the event loop. If `actionOnWindowClose` contains `Exit`, the application will exit; otherwise control will return to the function which called `mainLoop`.

If the application has two nested calls to `mainLoop` and calls `leaveMainLoop`, the behaviour is undefined. It may leave only the inner nested loop or it may leave both loops. If the reader has a strong preference for one behaviour over the other he should contact the freeglut Programming Consortium and ask for the code to be fixed.

# Controlling the behaviour when windows are closed

data ActionOnWindowClose Source #

The behaviour when the user closes a window.

Constructors

Exit | Exit the whole program when any window is closed or `leaveMainLoop` is called (default).
MainLoopReturns | Return from mainLoop when any window is closed.
ContinueExecution | Return from mainLoop after the last window is closed.

Instances

Eq ActionOnWindowClose Source # |
Methods (==) :: ActionOnWindowClose -> ActionOnWindowClose -> Bool # (/=) :: ActionOnWindowClose -> ActionOnWindowClose -> Bool #
Ord ActionOnWindowClose Source # |

Methods

compare :: ActionOnWindowClose -> ActionOnWindowClose -> Ordering #

(<) :: ActionOnWindowClose -> ActionOnWindowClose -> Bool #

(<=) :: ActionOnWindowClose -> ActionOnWindowClose -> Bool #

(>) :: ActionOnWindowClose -> ActionOnWindowClose -> Bool #

(>=) :: ActionOnWindowClose -> ActionOnWindowClose -> Bool #

max :: ActionOnWindowClose -> ActionOnWindowClose -> ActionOnWindowClose #

min :: ActionOnWindowClose -> ActionOnWindowClose -> ActionOnWindowClose #

Show ActionOnWindowClose Source # |
Methods showsPrec :: Int -> ActionOnWindowClose -> ShowS # show :: ActionOnWindowClose -> String # showList :: [ActionOnWindowClose] -> ShowS #

actionOnWindowClose :: StateVar ActionOnWindowClose Source #

(freeglut only) Controls the behaviour when the user closes a window.