UISF-0.4.0.0: Library for Arrowized Graphical User Interfaces.

Copyright(c) Daniel Winograd-Cort 2015
Licensesee the LICENSE file in the distribution
Maintainerdwc@cs.yale.edu
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

FRP.UISF.Render.GLUT

Contents

Description

 

Synopsis

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.

Instances

data WindowData Source

The WindowData object is used for communication between the logic (UISF) and the window (GLUT).

Constructors

WindowData 

Fields

setGraphics :: (Graphic, DirtyBit) -> IO ()

This action allows a caller to set the current Graphic to display along with a DirtyBit indicating if the Graphic needs to be redrawn.

getWindow :: IO (Maybe Window)

This action retrieves the active window. For now, this is used both to check if the GUI is still running (a result of Nothing indicates that it is not) and to externally close the window. Note that if GLUT closes the window (e.g. the user clicks the close button), this reference will be updated to Nothing to prevent double closure.

getWindowDim :: IO Dimension

This action retrieves the window's current dimensions. There is no way to set this value outside of the initial dimension provided by openWindow (perhaps a future feature).

getNextEvent :: IO UIEvent

This action retrieves the next keyboard/mouse event to be processed. In the case that there is no new event, NoUIEvent is provided.

peekNextEvent :: IO UIEvent

This action peeks at the next keyboard/mouse event to be processed. In the case that there is no new event, NoUIEvent is provided. This was added for a potential performance boost.

getElapsedGUITime :: IO Double

This action retrieves the number of real time seconds that have elapsed since the GUI began.

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.