Copyright | (c) Sven Panne 2002-2013 |
---|---|
License | BSD3 |
Maintainer | Sven Panne <svenpanne@gmail.com> |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- Redisplay callbacks
- Reshape callback
- Position callback
- Callbacks for visibility changes
- Window close callback
- Life cycle callbacks for mobile platforms
- Keyboard callback
- Special callback
- Mouse callback
- Keyboard and mouse input callback
- Mouse wheel callback
- Mouse movement callbacks
- Spaceball callback
- Dial & button box callback
- Tablet callback
- Joystick callback
- Multi-touch support
- type DisplayCallback = IO ()
- displayCallback :: SettableStateVar DisplayCallback
- overlayDisplayCallback :: SettableStateVar (Maybe DisplayCallback)
- type ReshapeCallback = Size -> IO ()
- reshapeCallback :: SettableStateVar (Maybe ReshapeCallback)
- type PositionCallback = Position -> IO ()
- positionCallback :: SettableStateVar (Maybe PositionCallback)
- data Visibility
- type VisibilityCallback = Visibility -> IO ()
- visibilityCallback :: SettableStateVar (Maybe VisibilityCallback)
- data WindowState
- type WindowStateCallback = WindowState -> IO ()
- windowStateCallback :: SettableStateVar (Maybe WindowStateCallback)
- type CloseCallback = IO ()
- closeCallback :: SettableStateVar (Maybe CloseCallback)
- type InitContextCallback = IO ()
- initContextCallback :: SettableStateVar (Maybe InitContextCallback)
- data AppStatus
- type AppStatusCallback = AppStatus -> IO ()
- appStatusCallback :: SettableStateVar (Maybe AppStatusCallback)
- type KeyboardCallback = Char -> Position -> IO ()
- keyboardCallback :: SettableStateVar (Maybe KeyboardCallback)
- keyboardUpCallback :: SettableStateVar (Maybe KeyboardCallback)
- type SpecialCallback = SpecialKey -> Position -> IO ()
- specialCallback :: SettableStateVar (Maybe SpecialCallback)
- specialUpCallback :: SettableStateVar (Maybe SpecialCallback)
- type MouseCallback = MouseButton -> KeyState -> Position -> IO ()
- mouseCallback :: SettableStateVar (Maybe MouseCallback)
- data Key
- data SpecialKey
- data MouseButton
- data KeyState
- data Modifiers = Modifiers {}
- type KeyboardMouseCallback = Key -> KeyState -> Modifiers -> Position -> IO ()
- keyboardMouseCallback :: SettableStateVar (Maybe KeyboardMouseCallback)
- type WheelNumber = Int
- type WheelDirection = Int
- type MouseWheelCallback = WheelNumber -> WheelDirection -> Position -> IO ()
- mouseWheelCallback :: SettableStateVar (Maybe MouseWheelCallback)
- type MotionCallback = Position -> IO ()
- motionCallback :: SettableStateVar (Maybe MotionCallback)
- passiveMotionCallback :: SettableStateVar (Maybe MotionCallback)
- data Crossing
- type CrossingCallback = Crossing -> IO ()
- crossingCallback :: SettableStateVar (Maybe CrossingCallback)
- type SpaceballMotion = Int
- type SpaceballRotation = Int
- type ButtonIndex = Int
- data SpaceballInput
- type SpaceballCallback = SpaceballInput -> IO ()
- spaceballCallback :: SettableStateVar (Maybe SpaceballCallback)
- data DialAndButtonBoxInput
- type DialIndex = Int
- type DialAndButtonBoxCallback = DialAndButtonBoxInput -> IO ()
- dialAndButtonBoxCallback :: SettableStateVar (Maybe DialAndButtonBoxCallback)
- data TabletPosition = TabletPosition Int Int
- data TabletInput
- type TabletCallback = TabletInput -> TabletPosition -> IO ()
- tabletCallback :: SettableStateVar (Maybe TabletCallback)
- data JoystickButtons = JoystickButtons {}
- data JoystickPosition = JoystickPosition Int Int Int
- type JoystickCallback = JoystickButtons -> JoystickPosition -> IO ()
- joystickCallback :: SettableStateVar (Maybe (JoystickCallback, PollRate))
- type TouchID = Int
- type MultiMouseCallback = TouchID -> MouseCallback
- multiMouseCallback :: SettableStateVar (Maybe MultiMouseCallback)
- type MultiCrossingCallback = TouchID -> CrossingCallback
- multiCrossingCallback :: SettableStateVar (Maybe MultiCrossingCallback)
- type MultiMotionCallback = TouchID -> MotionCallback
- multiMotionCallback :: SettableStateVar (Maybe MultiMotionCallback)
- multiPassiveMotionCallback :: SettableStateVar (Maybe MultiMotionCallback)
Redisplay callbacks
type DisplayCallback = IO () Source
A display callback
displayCallback :: SettableStateVar DisplayCallback Source
Controls 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 overlayDisplayCallback
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
(see damaged
) is cleared. If there is no overlay
display callback registered the overlay damaged state of the window (see
damaged
) is also cleared.
overlayDisplayCallback :: SettableStateVar (Maybe DisplayCallback) Source
Controls 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 (see damaged
) is cleared.
Initially there is no overlay display callback registered when an overlay is
established. See displayCallback
to understand how the display callback
alone is used if an overlay display callback is not registered.
Reshape callback
type ReshapeCallback = Size -> IO () Source
A reshape callback
reshapeCallback :: SettableStateVar (Maybe ReshapeCallback) Source
Controls 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 reshapeCallback
is
set to Nothing
(to deregister a previously registered callback), the
default reshape callback is used. This default callback will simply call
viewport
(Position
0 0) (Size
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 windowSize
.
Position callback
type PositionCallback = Position -> IO () Source
A position callback
positionCallback :: SettableStateVar (Maybe PositionCallback) Source
(freeglut only) Controls the position callback for the current window. The position callback for a window is called when the position of a window changes.
Callbacks for visibility changes
data Visibility Source
The visibility state of the current window
NotVisible | No part of the current window is visible, i.e., until the window's visibility changes, all further rendering to the window is discarded. |
Visible | 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. |
type VisibilityCallback = Visibility -> IO () Source
A visibility callback
visibilityCallback :: SettableStateVar (Maybe VisibilityCallback) Source
Controls 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.
Note that you can either use visibilityCallback
or windowStateCallback
,
but not both, because the former is implemented via the latter.
data WindowState Source
The window state of the current window
Unmapped | The current window is unmapped. |
FullyRetained | The current window is unobscured. |
PartiallyRetained | The current window is partially obscured. |
FullyCovered | The current window is fully obscured. |
type WindowStateCallback = WindowState -> IO () Source
A window state callback
windowStateCallback :: SettableStateVar (Maybe WindowStateCallback) Source
Controls the window state callback for the current window. The window state callback for a window is called when the window state of a window changes.
If the window state callback for a window is disabled and later re-enabled, the window state state of the window is undefined; any change in the window state will be reported, that is if you disable a window state callback and re-enable the callback, you are guaranteed the next window state change will be reported.
Note that you can either use visibilityCallback
or windowStateCallback
,
but not both, because the former is implemented via the latter.
Window close callback
type CloseCallback = IO () Source
A window close callback
closeCallback :: SettableStateVar (Maybe CloseCallback) Source
Controls the window close callback for the current window.
Life cycle callbacks for mobile platforms
type InitContextCallback = IO () Source
An initialize context callback
initContextCallback :: SettableStateVar (Maybe InitContextCallback) Source
(freeglut only) Controls the initialize context callback for the /current window/.
The application status of the current window
type AppStatusCallback = AppStatus -> IO () Source
An application status callback
appStatusCallback :: SettableStateVar (Maybe AppStatusCallback) Source
Controls the application status callback for the current window.
Keyboard callback
type KeyboardCallback = Char -> Position -> IO () Source
A keyboard callback
keyboardCallback :: SettableStateVar (Maybe KeyboardCallback) Source
Controls the keyboard callback for the current window. This is activated only when a key is pressed.
keyboardUpCallback :: SettableStateVar (Maybe KeyboardCallback) Source
Controls the keyboard callback for the current window. This is activated only when a key is released.
Special callback
type SpecialCallback = SpecialKey -> Position -> IO () Source
A special key callback
specialCallback :: SettableStateVar (Maybe SpecialCallback) Source
Controls the special key callback for the current window. This is activated only when a special key is pressed.
specialUpCallback :: SettableStateVar (Maybe SpecialCallback) Source
Controls the special key callback for the current window. This is activated only when a special key is released.
Mouse callback
type MouseCallback = MouseButton -> KeyState -> Position -> IO () Source
A mouse callback
mouseCallback :: SettableStateVar (Maybe MouseCallback) Source
Controls the mouse callback for the current window.
Keyboard and mouse input callback
A generalized view of keys
data SpecialKey Source
Special keys
KeyF1 | |
KeyF2 | |
KeyF3 | |
KeyF4 | |
KeyF5 | |
KeyF6 | |
KeyF7 | |
KeyF8 | |
KeyF9 | |
KeyF10 | |
KeyF11 | |
KeyF12 | |
KeyLeft | |
KeyUp | |
KeyRight | |
KeyDown | |
KeyPageUp | |
KeyPageDown | |
KeyHome | |
KeyEnd | |
KeyInsert | |
KeyNumLock | |
KeyBegin | |
KeyDelete | |
KeyShiftL | |
KeyShiftR | |
KeyCtrlL | |
KeyCtrlR | |
KeyAltL | |
KeyAltR | |
KeyUnknown Int | You should actually never encounter this value, it is just here as a safeguard against future changes in the native GLUT library. |
data MouseButton Source
Mouse buttons, including a wheel
The current state of a key or button
The state of the keyboard modifiers
type KeyboardMouseCallback = Key -> KeyState -> Modifiers -> Position -> IO () Source
A keyboard/mouse callback
keyboardMouseCallback :: SettableStateVar (Maybe KeyboardMouseCallback) Source
Controls the keyboard/mouse callback for the current window. The keyboard/mouse callback for a window is called when the state of a key or mouse button changes. The callback parameters indicate the new state of the key/button, the state of the keyboard modifiers, and the mouse location in window relative coordinates.
Note that this is a convenience function that should not ordinarily be used
in conjunction with keyboardCallback
, keyboardUpCallback
,
specialCallback
, specialUpCallback
, or mouseCallback
.
Mouse wheel callback
type WheelNumber = Int Source
type WheelDirection = Int Source
type MouseWheelCallback = WheelNumber -> WheelDirection -> Position -> IO () Source
mouseWheelCallback :: SettableStateVar (Maybe MouseWheelCallback) Source
(freeglut only) Controls the mouse wheel callback for the
current window. The mouse wheel callback for a window is called when a
mouse wheel is used and the wheel number is greater than or equal to
numMouseButtons
.
Mouse movement callbacks
type MotionCallback = Position -> IO () Source
A motion callback
motionCallback :: SettableStateVar (Maybe MotionCallback) Source
Controls 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.
passiveMotionCallback :: SettableStateVar (Maybe MotionCallback) Source
Controls 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.
The relation between the mouse pointer and the current window has changed.
WindowLeft | The mouse pointer has left the current window. |
WindowEntered | The mouse pointer has entered the current window. |
type CrossingCallback = Crossing -> IO () Source
An enter/leave callback
crossingCallback :: SettableStateVar (Maybe CrossingCallback) Source
Controls 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 = Int Source
Translation of the Spaceball along one axis, normalized to be in the range of -1000 to +1000 inclusive
type SpaceballRotation = Int Source
Rotation of the Spaceball along one axis, normalized to be in the range of -1800 .. +1800 inclusive
type ButtonIndex = Int Source
The index of a specific buttons of an input device.
data SpaceballInput Source
The state of the Spaceball has changed.
type SpaceballCallback = SpaceballInput -> IO () Source
A SpaceballButton callback
spaceballCallback :: SettableStateVar (Maybe SpaceballCallback) Source
Controls 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 numSpaceballButtons
.
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 Source
The dial & button box state has changed.
type DialAndButtonBoxCallback = DialAndButtonBoxInput -> IO () Source
A dial & button box callback
dialAndButtonBoxCallback :: SettableStateVar (Maybe DialAndButtonBoxCallback) Source
Controls 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
numDialsAndButtons
.
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 Source
Absolute tablet position, with coordinates normalized to be in the range of 0 to 2000 inclusive
data TabletInput Source
The table state has changed.
type TabletCallback = TabletInput -> TabletPosition -> IO () Source
A tablet callback
tabletCallback :: SettableStateVar (Maybe TabletCallback) Source
Controls 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
numTabletButtons
.
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 Source
The state of the joystick buttons
data JoystickPosition Source
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
type JoystickCallback = JoystickButtons -> JoystickPosition -> IO () Source
A joystick callback
joystickCallback :: SettableStateVar (Maybe (JoystickCallback, PollRate)) Source
Controls 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.
Multi-touch support
A description where the multi-touch event is coming from, the freeglut specs are very vague about the actual semantics. It contains the device ID and/or the cursor/finger ID.
type MultiMouseCallback = TouchID -> MouseCallback Source
A multi-touch variant of MouseCallback
.
multiMouseCallback :: SettableStateVar (Maybe MultiMouseCallback) Source
(freeglut only) A multi-touch variant of mouseCallback
.
type MultiCrossingCallback = TouchID -> CrossingCallback Source
A multi-touch variant of CrossingCallback
.
multiCrossingCallback :: SettableStateVar (Maybe MultiCrossingCallback) Source
(freeglut only) A multi-touch variant of crossingCallback
.
type MultiMotionCallback = TouchID -> MotionCallback Source
A multi-touch variant of MotionCallback
.
multiMotionCallback :: SettableStateVar (Maybe MultiMotionCallback) Source
(freeglut only) A multi-touch variant of motionCallback
.
multiPassiveMotionCallback :: SettableStateVar (Maybe MultiMotionCallback) Source
(freeglut only) A multi-touch variant of passiveMotionCallback
.