Copyright | (c) Daniel Winograd-Cort 2015 |
---|---|
License | see the LICENSE file in the distribution |
Maintainer | dwc@cs.yale.edu |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
- data Window :: *
- data WindowData = WindowData {
- setGraphics :: (Graphic, DirtyBit) -> IO ()
- getWindow :: IO (Maybe Window)
- getWindowDim :: IO Dimension
- getNextEvent :: IO UIEvent
- peekNextEvent :: IO UIEvent
- getElapsedGUITime :: IO Double
- openWindow :: RGB -> String -> Dimension -> IO WindowData
- closeWindow :: Window -> IO ()
- renderGraphicInOpenGL :: Dimension -> Graphic -> IO ()
- glutKeyToKey :: Key -> Key
Documentation
This module provides the functions for UISF's direct interface with
GLUT and the GUI window itself. The main function for this is
openWindow
, and once a window is open, almost all communication is
handled through the returned WindowData
object. The one exception
to this is that one can externally close the window,
terminating the GUI altogether (although this requires the window
object, which is found in the WindowData).
Note that the values in WindowData are all IO actions. Thus, to get
the "current" value of the window's dimensions, one should run the
windowDim
action "now".
Note also that the Window
type is being re-exported here as it is
used in the WindowData
type.
data Window :: *
An opaque identifier for a top-level window or a subwindow.
data WindowData Source
The WindowData object is used for communication between the logic (UISF) and the window (GLUT).
WindowData | |
|
openWindow :: RGB -> String -> Dimension -> IO WindowData Source
This function creates the GUI window. It takes as arguments a default background color, a title for the window, and the initial dimensions for the window; it produces a WindowData object to use as communication to the window.
Note that the main GLUT loop is run in a separate OS thread produced by forkOS.
closeWindow :: Window -> IO () Source
When provided with an active window, this function will close the window.
Rendering Graphics in OpenGL
renderGraphicInOpenGL :: Dimension -> Graphic -> IO () Source
This function takes the current dimensions of the window
(necessary for the bounding operation boundGraphic
) and a Graphic
and produces the OpenGL IO action that actually performs the
rendering. Two notes about it:
- Currently, it is using
Fixed8By13
for rendering text. - I have had some trouble with nesting uses of PreservingMatrix and scissoring, so bounded graphics (and perhaps other graphic transformations in general) may be a little buggy.
glutKeyToKey :: Key -> Key Source
Convert GLUT's key codes to UISF's internal ones.