HOpenGL Libraries (GLUT package)ParentContentsIndex
Graphics.UI.GLUT.Callbacks.Window
Portability portable
Stability experimental
Maintainer sven_panne@yahoo.com
Contents
Redisplay callbacks
Reshape callback
Callback for visibility changes
Keyboard and mouse input callback
Mouse movement callbacks
Spaceball callback
Dial & button box callback
Tablet callback
Joystick callback
Description
Synopsis
type DisplayCallback = IO ()
setDisplayCallback :: DisplayCallback -> IO ()
setOverlayDisplayCallback :: Maybe DisplayCallback -> IO ()
type ReshapeCallback = WindowSize -> IO ()
setReshapeCallback :: Maybe ReshapeCallback -> IO ()
data Visibility
= NotVisible
| Visible
type VisibilityCallback = Visibility -> IO ()
setVisibilityCallback :: Maybe VisibilityCallback -> IO ()
data Key
= Char Char
| SpecialKey SpecialKey
| MouseButton MouseButton
data SpecialKey
= KeyF1
| KeyF2
| KeyF3
| KeyF4
| KeyF5
| KeyF6
| KeyF7
| KeyF8
| KeyF9
| KeyF10
| KeyF11
| KeyF12
| KeyLeft
| KeyUp
| KeyRight
| KeyDown
| KeyPageUp
| KeyPageDown
| KeyHome
| KeyEnd
| KeyInsert
data MouseButton
= LeftButton
| MiddleButton
| RightButton
| WheelUp
| WheelDown
data KeyState
= Down
| Up
data Modifiers = Modifiers {
shift, ctrl, alt :: Bool
}
type KeyboardMouseCallback = Key -> KeyState -> Modifiers -> WindowPosition -> IO ()
setKeyboardMouseCallback :: Maybe KeyboardMouseCallback -> IO ()
marshalMouseButton :: MouseButton -> CInt
type MotionCallback = WindowPosition -> IO ()
setMotionCallback :: Maybe MotionCallback -> IO ()
setPassiveMotionCallback :: Maybe MotionCallback -> IO ()
data Crossing
= WindowLeft
| WindowEntered
type CrossingCallback = Crossing -> IO ()
setCrossingCallback :: Maybe CrossingCallback -> IO ()
type SpaceballMotion = CInt
type SpaceballRotation = CInt
data SpaceballInput
= SpaceballMotion SpaceballMotion SpaceballMotion SpaceballMotion
| SpaceballRotation SpaceballRotation SpaceballRotation SpaceballRotation
| SpaceballButton NumButtons KeyState
type SpaceballCallback = SpaceballInput -> IO ()
setSpaceballCallback :: Maybe SpaceballCallback -> IO ()
data DialAndButtonBoxInput
= DialAndButtonBoxButton NumButtons KeyState
| DialAndButtonBoxDial NumDials CInt
type DialAndButtonBoxCallback = DialAndButtonBoxInput -> IO ()
setDialAndButtonBoxCallback :: Maybe DialAndButtonBoxCallback -> IO ()
data TabletPosition = TabletPosition CInt CInt
data TabletInput
= TabletMotion
| TabletButton NumButtons KeyState
type TabletCallback = TabletInput -> TabletPosition -> IO ()
setTabletCallback :: Maybe TabletCallback -> IO ()
data JoystickButtons = JoystickButtons {
joystickButtonA, joystickButtonB, joystickButtonC, joystickButtonD :: Bool
}
data JoystickPosition = JoystickPosition CInt CInt CInt
setJoystickCallback :: Maybe JoystickCallback -> PollRate -> IO ()
Redisplay callbacks
type DisplayCallback = IO ()
setDisplayCallback :: DisplayCallback -> IO ()

Set the display callback for the current window. When GLUT determines that the normal plane for the window needs to be redisplayed, the display callback for the window is called. Before the callback, the current window is set to the window needing to be redisplayed and (if no overlay display callback is registered) the layer in use is set to the normal plane. The entire normal plane region should be redisplayed in response to the callback (this includes ancillary buffers if your program depends on their state).

GLUT determines when the display callback should be triggered based on the window's redisplay state. The redisplay state for a window can be either set explicitly by calling postRedisplay or implicitly as the result of window damage reported by the window system. Multiple posted redisplays for a window are coalesced by GLUT to minimize the number of display callbacks called.

When an overlay is established for a window, but there is no overlay display callback registered, the display callback is used for redisplaying both the overlay and normal plane (that is, it will be called if either the redisplay state or overlay redisplay state is set). In this case, the layer in use is not implicitly changed on entry to the display callback.

See setOverlayDisplayCallback to understand how distinct callbacks for the overlay and normal plane of a window may be established.

When a window is created, no display callback exists for the window. It is the responsibility of the programmer to install a display callback for the window before the window is shown. A display callback must be registered for any window that is shown. If a window becomes displayed without a display callback being registered, a fatal error occurs. There is no way to "deregister" a display callback (though another callback routine can always be registered).

Upon return from the display callback, the normal damaged state of the window (returned by calling isNormalDamaged) is cleared. If there is no overlay display callback registered the overlay damaged state of the window (returned by calling isOverlayDamaged) is also cleared.

setOverlayDisplayCallback :: Maybe DisplayCallback -> IO ()

Set the overlay display callback for the current window. The overlay display callback is functionally the same as the window's display callback except that the overlay display callback is used to redisplay the window's overlay.

When GLUT determines that the overlay plane for the window needs to be redisplayed, the overlay display callback for the window is called. Before the callback, the current window is set to the window needing to be redisplayed and the layer in use is set to the overlay. The entire overlay region should be redisplayed in response to the callback (this includes ancillary buffers if your program depends on their state).

GLUT determines when the overlay display callback should be triggered based on the window's overlay redisplay state. The overlay redisplay state for a window can be either set explicitly by calling postOverlayRedisplay or implicitly as the result of window damage reported by the window system. Multiple posted overlay redisplays for a window are coalesced by GLUT to minimize the number of overlay display callbacks called.

Upon return from the overlay display callback, the overlay damaged state of the window (returned by calling isOverlayDamaged) is cleared.

Initially there is no overlay display callback registered when an overlay is established. See setDisplayCallback to understand how the display callback alone is used if an overlay display callback is not registered.

Reshape callback
type ReshapeCallback = WindowSize -> IO ()
setReshapeCallback :: Maybe ReshapeCallback -> IO ()

Set the reshape callback for the current window. The reshape callback is triggered when a window is reshaped. A reshape callback is also triggered immediately before a window's first display callback after a window is created or whenever an overlay for the window is established. The parameter of the callback specifies the new window size in pixels. Before the callback, the current window is set to the window that has been reshaped.

If a reshape callback is not registered for a window or Nothing is passed to setReshapeCallback (to deregister a previously registered callback), the default reshape callback is used. This default callback will simply call

 viewport (WindowPosition 0 0) (WindowSize width height)
 

on the normal plane (and on the overlay if one exists).

If an overlay is established for the window, a single reshape callback is generated. It is the callback's responsibility to update both the normal plane and overlay for the window (changing the layer in use as necessary).

When a top-level window is reshaped, subwindows are not reshaped. It is up to the GLUT program to manage the size and positions of subwindows within a top-level window. Still, reshape callbacks will be triggered for subwindows when their size is changed using reshapeWindow.

Callback for visibility changes
data Visibility
The visibility state of the current window
Constructors
NotVisible The current window is totally or partially visible. GLUT considers a window visible if any pixel of the window is visible or any pixel of any descendant window is visible on the screen.
Visible No part of the current window is visible, i.e., until the window's visibility changes, all further rendering to the window is discarded.
Instances
Eq Visibility
Ord Visibility
type VisibilityCallback = Visibility -> IO ()
setVisibilityCallback :: Maybe VisibilityCallback -> IO ()

Set the visibility callback for the current window. The visibility callback for a window is called when the visibility of a window changes.

If the visibility callback for a window is disabled and later re-enabled, the visibility status of the window is undefined; any change in window visibility will be reported, that is if you disable a visibility callback and re-enable the callback, you are guaranteed the next visibility change will be reported.

Keyboard and mouse input callback
data Key
Constructors
Char Char
SpecialKey SpecialKey
MouseButton MouseButton
Instances
Eq Key
Ord Key
data SpecialKey
Constructors
KeyF1
KeyF2
KeyF3
KeyF4
KeyF5
KeyF6
KeyF7
KeyF8
KeyF9
KeyF10
KeyF11
KeyF12
KeyLeft
KeyUp
KeyRight
KeyDown
KeyPageUp
KeyPageDown
KeyHome
KeyEnd
KeyInsert
Instances
Eq SpecialKey
Ord SpecialKey
data MouseButton
Constructors
LeftButton
MiddleButton
RightButton
WheelUp
WheelDown
Instances
Eq MouseButton
Ord MouseButton
data KeyState
Constructors
Down
Up
Instances
Eq KeyState
Ord KeyState
data Modifiers
Constructors
Modifiers
shift, ctrl, alt :: Bool
Instances
Eq Modifiers
Ord Modifiers
type KeyboardMouseCallback = Key -> KeyState -> Modifiers -> WindowPosition -> IO ()
setKeyboardMouseCallback :: Maybe KeyboardMouseCallback -> IO ()
marshalMouseButton :: MouseButton -> CInt
Mouse movement callbacks
type MotionCallback = WindowPosition -> IO ()
setMotionCallback :: Maybe MotionCallback -> IO ()
Set the motion callback for the current window. The motion callback for a window is called when the mouse moves within the window while one or more mouse buttons are pressed. The callback parameter indicates the mouse location in window relative coordinates.
setPassiveMotionCallback :: Maybe MotionCallback -> IO ()
Set the passive motion callback for the current window. The passive motion callback for a window is called when the mouse moves within the window while no mouse buttons are pressed. The callback parameter indicates the mouse location in window relative coordinates.
data Crossing
Constructors
WindowLeft The mouse pointer has left the current window.
WindowEntered The mouse pointer has entered the current window.
Instances
Eq Crossing
Ord Crossing
type CrossingCallback = Crossing -> IO ()
setCrossingCallback :: Maybe CrossingCallback -> IO ()

Set the mouse enter/leave callback for the current window. Note that some window systems may not generate accurate enter/leave callbacks.

X Implementation Notes: An X implementation of GLUT should generate accurate enter/leave callbacks.

Spaceball callback
type SpaceballMotion = CInt
Translation of the Spaceball along one axis, normalized to be in the range of -1000 to +1000 inclusive
type SpaceballRotation = CInt
Rotation of the Spaceball along one axis, normalized to be in the range of -1800 .. +1800 inclusive
data SpaceballInput
Constructors
SpaceballMotion SpaceballMotion SpaceballMotion SpaceballMotion
SpaceballRotation SpaceballRotation SpaceballRotation SpaceballRotation
SpaceballButton NumButtons KeyState
type SpaceballCallback = SpaceballInput -> IO ()
setSpaceballCallback :: Maybe SpaceballCallback -> IO ()

Set the Spaceball callback for the current window. The Spaceball callback for a window is called when the window has Spaceball input focus (normally, when the mouse is in the window) and the user generates Spaceball translations, rotations, or button presses. The number of available Spaceball buttons can be determined with getSpaceballInfo.

Registering a Spaceball callback when a Spaceball device is not available has no effect and is not an error. In this case, no Spaceball callbacks will be generated.

Dial & button box callback
data DialAndButtonBoxInput
Constructors
DialAndButtonBoxButton NumButtons KeyState
DialAndButtonBoxDial NumDials CInt
Instances
Eq DialAndButtonBoxInput
Ord DialAndButtonBoxInput
type DialAndButtonBoxCallback = DialAndButtonBoxInput -> IO ()
setDialAndButtonBoxCallback :: Maybe DialAndButtonBoxCallback -> IO ()

Set the dial & button box callback for the current window. The dial & button box button callback for a window is called when the window has dial & button box input focus (normally, when the mouse is in the window) and the user generates dial & button box button presses or dial changes. The number of available dial & button box buttons and dials can be determined with getDialAndButtonBoxInfo.

Registering a dial & button box callback when a dial & button box device is not available is ineffectual and not an error. In this case, no dial & button box button will be generated.

Tablet callback
data TabletPosition
Absolute tablet position, with coordinates normalized to be in the range of 0 to 2000 inclusive
Constructors
TabletPosition CInt CInt
data TabletInput
Constructors
TabletMotion
TabletButton NumButtons KeyState
type TabletCallback = TabletInput -> TabletPosition -> IO ()
setTabletCallback :: Maybe TabletCallback -> IO ()

Set the tablet callback for the current window. The tablet callback for a window is called when the window has tablet input focus (normally, when the mouse is in the window) and the user generates tablet motion or button presses. The number of available tablet buttons can be determined with getTabletInfo.

Registering a tablet callback when a tablet device is not available is ineffectual and not an error. In this case, no tablet callbacks will be generated.

Joystick callback
data JoystickButtons
Constructors
JoystickButtons
joystickButtonA, joystickButtonB, joystickButtonC, joystickButtonD :: Bool
Instances
Eq JoystickButtons
Ord JoystickButtons
data JoystickPosition

Absolute joystick position, with coordinates normalized to be in the range of -1000 to 1000 inclusive. The signs of the three axes mean the following:

  • negative = left, positive = right
  • negative = towards player, positive = away
  • if available (e.g. rudder): negative = down, positive = up
Constructors
JoystickPosition CInt CInt CInt
Instances
Eq JoystickPosition
Ord JoystickPosition
setJoystickCallback :: Maybe JoystickCallback -> PollRate -> IO ()

Set the joystick callback for the current window. The joystick callback is called either due to polling of the joystick at the uniform timer interval specified (if > 0) or in response to an explicit call of forceJoystickCallback.

X Implementation Notes: Currently GLUT has no joystick support for X11.

Produced by Haddock version 0.5