wgpu-hs-0.1.0.0: WGPU
Safe HaskellNone
LanguageHaskell2010

WGPU.Internal.Instance

Description

Instance of the WGPU API Haskell bindings.

Synopsis

Instance

The Haskell bindings to WGPU use a value of type Instance as a handle to the rest of the API. An Instance value is obtained by loading a dynamic library at runtime, using the withInstance function. A typical invocation might look like this:

withInstance "libwgpu_native.dylib" (Just logStdOut) $ inst -> do
  -- set the logging level for the instance
  setLogLevel inst Warn
  -- run the rest of the program ...

The dynamic library libwgpu_native.dylib is obtained by compiling the Rust project wgpu-native. Care should be take to compile a version of libwgpu_native.dylib which is compatible with the API in these bindings.

newtype Instance Source #

Instance of the WGPU API.

An instance is loaded from a dynamic library using the withInstance function.

Constructors

Instance 

Instances

Instances details
Show Instance Source # 
Instance details

Defined in WGPU.Internal.Instance

ToRaw Instance WGPUHsInstance Source # 
Instance details

Defined in WGPU.Internal.Instance

withInstance Source #

Arguments

:: FilePath

Name of the wgpu-native dynamic library, or a complete path to it.

-> Maybe LogCallback

Optional logging callback. Just logStdout can be supplied here to print log messages to stdout for debugging purposes.

-> (Instance -> IO a)

The Program. A function which takes an Instance and returns an IO action that uses the instance.

-> IO a

IO action which loads the WGPU Instance, passes it to the program, and returns the result of running the program.

Load the WGPU API from a dynamic library and supply an Instance to a program.

Logging

type LogCallback = LogLevel -> Text -> IO () Source #

Logging callback function.

data LogLevel Source #

Logging level.

Constructors

Trace 
Debug 
Info 
Warn 
Error 

Instances

Instances details
Eq LogLevel Source # 
Instance details

Defined in WGPU.Internal.Instance

Show LogLevel Source # 
Instance details

Defined in WGPU.Internal.Instance

setLogLevel :: Instance -> LogLevel -> IO () Source #

Set the current logging level for the instance.

logLevelToText :: LogLevel -> Text Source #

Convert a LogLevel to a text string.

logStdout :: LogLevel -> Text -> IO () Source #

A logging function which prints to stdout.

This logging function can be supplied to withInstance to print logging messages to stdout for debugging purposes.

Version

data Version Source #

Version of WGPU native.

Constructors

Version 

Fields

Instances

Instances details
Eq Version Source # 
Instance details

Defined in WGPU.Internal.Instance

Methods

(==) :: Version -> Version -> Bool #

(/=) :: Version -> Version -> Bool #

Show Version Source # 
Instance details

Defined in WGPU.Internal.Instance

getVersion :: Instance -> IO Version Source #

Return the exact version of the WGPU native instance.

versionToText :: Version -> Text Source #

Convert a Version value to a text string.

>>> versionToText (Version 0 9 2 2)
"v0.9.2.2"