GPipe-GLFW-1.4.1.3: GLFW OpenGL context creation for GPipe

Safe HaskellNone
LanguageHaskell2010

Graphics.GPipe.Context.GLFW

Contents

Description

Non interactive applications only need to pass configuration defined here into GPipe's runContextT and newWindow.

Interactive applications will need Graphics.GPipe.Context.GLFW.Input.

Synopsis

GPipe context handler for GLFW

data Handle Source #

Opaque handle representing the initialized GLFW library.

To get started quickly try defaultHandleConfig and defaultWindowConfig.

     import Graphics.GPipe
     import qualified Graphics.GPipe.Context.GLFW as GLFW

     runContextT GLFW.defaultHandleConfig $ do
         win <- newWindow (WindowFormatColorDepth RGB8 Depth16) (GLFW.defaultWindowConfig "OpenGL Graphics")
         -- Do GPipe things here

data GLFWWindow Source #

Opaque handle representing a, possibly closed, internal Context. You'll typically deal with GPipe's Window instead of this one.

Configuration

Default configs

defaultHandleConfig :: ContextHandlerParameters Handle Source #

Default GLFW handle configuration.

  • Print any errors that GLFW emits.
  • Automatically process GLFW events after every buffer swap.

defaultWindowConfig :: String -> WindowConfig Source #

Default window configuration for a small window on any monitor with the given title.

Custom configs

data family ContextHandlerParameters ctx :: Type #

Implementation specific context handler parameters, eg error handling and event processing policies

Configuration for the GLFW handle.

HandleConfig
Constructor
configErrorCallback :: Error -> String -> IO ()
Specify a callback to handle errors emitted by GLFW.
configEventPolicy :: Maybe EventPolicy
Specify the EventPolicy to use for automatic GLFW event processing. If Nothing then automatic event processing is disabled and you'll need to call mainloop or mainstep somewhere.

data WindowConfig Source #

Configuration for a new GLFW window and associated OpenGL context.

data EventPolicy Source #

Type to describe the waiting or polling style of event processing supported by GLFW.

Constructors

Poll 
Wait 

Exceptions

Mainthread hooks

mainloop Source #

Arguments

:: MonadIO m 
=> Window os c ds 
-> EventPolicy

A Poll loop runs continuously while a Wait loop sleeps until events or user input occur.

-> ContextT Handle os m (Maybe ()) 

Process GLFW and GPipe events according to the given EventPolicy in a loop.

Use case: Call mainloop in multithreaded applications which do GPipe rendering off of the main thread, but which do not otherwise need additional control over the main thread. For less complex applications use automatic event processing configured via HandleConfig.

  • Must be called on the main thread.
  • The loop will run until windowShouldClose is true for the all Windows created by the same ContextHandler, or all the Windows have been deleted.
  • To indicate a window should close use setWindowShouldClose in Graphics.GPipe.Context.GLFW.Wrapped.

mainstep Source #

Arguments

:: MonadIO m 
=> Window os c ds 
-> EventPolicy

Poll will process events and return immediately while Wait will sleep until events are received.

-> ContextT Handle os m (Maybe ()) 

Process GLFW and GPipe events according to the given EventPolicy.

Use case: Call mainstep as part of a custom engine loop in multithreaded applications which do GPipe rendering off of the main thread. Use mainloop for less complex applications.

  • Must be called on the main thread.
  • Can be called with any window you've created and not yet deleted.
  • If GPipe can't find the window you passed in, returns Nothing.

Reexports