wgpu-hs-0.3.0.0: WGPU
Safe HaskellNone
LanguageHaskell2010

WGPU.BoneYard.SimpleSDL

Description

This is a kind of skeleton for a very simple SDL app. It is intended for bootstrapping development. A common use case is when you want a window to draw in with everything configured. This provides a version of that functionality that can later be replaced or refined (easily) by the app developer if necessary.

Synopsis

Swap Chain

Types

data SwapChainState Source #

Contains mutable state to manage the swap chain.

Functions

withSwapChain :: forall r m a. (HasDevice r m, HasSurface r m, HasAdapter r m, Has Window r, Has SwapChainState r) => ReaderT (SwapChain, r) m a -> m a Source #

Provide a ReaderT with a properly-configured SwapChain.

Render Pipelines

Types

data RenderPipelines Source #

Container for mutable state that contains a map of render pipelines.

Functions

createRenderPipeline Source #

Arguments

:: (MonadIO m, HasDevice r m, Has RenderPipelines r) 
=> RenderPipelineName

Name of the render pipeline.

-> RenderPipelineDescriptor

Descriptor of the render pipeline.

-> m RenderPipeline

The created render pipeline.

Create a RenderPipeline, storing it in the RenderPipelines map.

A RenderPipeline created this way can be fetched using getRenderPipeline. This calls createRenderPipeline under the hood.

getRenderPipeline Source #

Arguments

:: (Has RenderPipelines r, MonadReader r m, MonadIO m, MonadThrow m) 
=> RenderPipelineName

Name of the render pipeline to fetch.

-> m RenderPipeline

The render pipeline.

Fetch a render pipeline that was previously created using createRenderPipeline.

If the render pipeline is not available, this function throws an exception of type AppException.

Shaders

Types

data Shaders Source #

Container for mutable state that contains a map of shaders.

Functions

emptyShaders :: MonadResource m => m Shaders Source #

Create an empty Shaders.

compileWGSL Source #

Arguments

:: (Has Device r, Has Shaders r, MonadReader r m, MonadResource m) 
=> ShaderName

Name of the shader.

-> WGSL

Shader source code.

-> m ShaderModule

Action that returns the compiled shader module, after adding it to the Shaders map.

Compile a WGSL shader, adding it to the Shaders map, and returning the compiled ShaderModule.

compileWGSL_ Source #

Arguments

:: (Has Device r, Has Shaders r, MonadReader r m, MonadResource m) 
=> ShaderName

Name of the shader.

-> WGSL

Shader source code.

-> m ()

Action that compiles the shader and adds it to the Shaders map.

Compile a WGSL shader, adding it to the Shaders map.

getShader Source #

Arguments

:: (Has Shaders r, MonadReader r m, MonadIO m, MonadThrow m) 
=> ShaderName

Name of the shader to fetch.

-> m ShaderModule

The shader module.

Fetch a shader that was previously compiled.

If the shader is not available, this function throws an exception of type AppException.

Resources

Types

data Params Source #

Parameters for initialization.

Constructors

Params 

Fields

data Resources Source #

Resources for the app.

Constructors

Resources 

Instances

Instances details
Generic Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Associated Types

type Rep Resources :: Type -> Type #

Has Window Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Queue Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Device Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Adapter Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Surface Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Instance Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

type Rep Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Functions

loadResources Source #

Arguments

:: forall m. (MonadResource m, MonadThrow m) 
=> Params

Initialization parameters.

-> m Resources

Created application resources.

Load the resources for an application.

This creates: - Instance, - SDL Window (which is shown) - Surface for the SDL window - Adapter - Device - Queue

Exceptions

data AppException Source #

Exceptions from SimpleSDL.

Constructors

AdapterRequestFailed

Requesting an adapter failed.

DeviceRequestFailed

Requesting a device failed.

UnknownShaderName ShaderName

Requesting a shader failed.

UnknownRenderPipelineName RenderPipelineName

Requesting a render pipeline failed.