Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module provides utilities to create usable NanoVG contexts in GLFW windows.
Documentation
Simple example:
import Graphics.NanoVG.Simple import qualified NanoVG as NVG main :: IO () main = run 800 600 "Simple app" $ simpleWindow $ NVG.circle ctx 10 10 10 *> NVG.fill ctx
Windows
Window keep state and repeatedly calls render/afterRender.
Invocation of winRender
action happens inside nanovg frame, so you can use
the provided context to render whatever you want. The buffers are cleared before
each frame.
There is no interface to update state directly so mutable containers should be used, if so desired.
simpleWindow :: (Context -> IO ()) -> Window () Source #
Create new window which does not need own persistent state.
:: Int | Initial window width. |
-> Int | Initial window height. |
-> String | Window title. |
-> Window st | Rendering instructions to be executed in the context of the new window. |
-> IO () |
Run given rendering instructions (Window
structure) in new GLFW window of given size and title.
NOTE: It is currently impossible to run multiple windows simultaneously in same application.
Middlewares
type MiddleWare st0 st = Window st0 -> Window st Source #
Middleware adds some piece of functionality to existing window.
:: Text | Alias of the font to render text with. Refer to |
-> MiddleWare a (Data, a) |
This middleware shows FPS counter in top left corner of the window.
:: Text | File path to load font from. Font is loaded with freetype2 so refer to it's documentation for allowed formats. |
-> Text | Alias which can later be used to refer to the loaded font. |
-> MiddleWare a a |
Load font from of the supported file formats and store it under given alias for further use.