dynamic-graph-0.1.0.13: Draw and update graphs in real time with OpenGL

Safe HaskellNone
LanguageHaskell2010

Graphics.DynamicGraph.Window

Description

A convenience function for rendering any of the graphs implemented in this package to a standalone window.

Example usage:

import Control.Monad
import Control.Monad.Trans.Except
import Control.Error.Util
import Control.Concurrent
import Pipes
import qualified Pipes.Prelude as P
import System.Random
import Graphics.Rendering.OpenGL

import Graphics.DynamicGraph.Waterfall
import Graphics.DynamicGraph.Window

randomVect :: Producer [GLfloat] IO ()
randomVect =  P.repeatM $ do
    res <- replicateM 1000 randomIO
    threadDelay 10000
    return res

main = exceptT putStrLn return $ do
    res <- lift setupGLFW
    unless res (throwE "Unable to initilize GLFW")

    waterfall <- window 1024 480 $ renderWaterfall 1000 1000 jet_mod

    lift $ runEffect $ randomVect >-> waterfall
Synopsis

Documentation

window Source #

Arguments

:: IsPixelData a 
=> Int

Window width

-> Int

Window height

-> IO (Consumer a IO ())

The Consumer that draws on the window. Obtain this from one of the other modules in this package. Must be given in an IO monad so that it can be initialised with the OpenGL context created within this function.

-> ExceptT String IO (Consumer a IO ()) 

A convenience function for rendering any of the graphs implemented in this package to a standalone window.

Creates the window before returning.

Returns either an error message or a consumer that draws to the window.