Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data SwapChainState
- emptySwapChainState :: MonadResource m => m SwapChainState
- 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
- data RenderPipelineName
- data RenderPipelines
- emptyRenderPipelines :: MonadResource m => m RenderPipelines
- createRenderPipeline :: (MonadIO m, HasDevice r m, Has RenderPipelines r) => RenderPipelineName -> RenderPipelineDescriptor -> m RenderPipeline
- getRenderPipeline :: (Has RenderPipelines r, MonadReader r m, MonadIO m, MonadThrow m) => RenderPipelineName -> m RenderPipeline
- data ShaderName
- data Shaders
- emptyShaders :: MonadResource m => m Shaders
- compileWGSL :: (Has Device r, Has Shaders r, MonadReader r m, MonadResource m) => ShaderName -> WGSL -> m ShaderModule
- compileWGSL_ :: (Has Device r, Has Shaders r, MonadReader r m, MonadResource m) => ShaderName -> WGSL -> m ()
- getShader :: (Has Shaders r, MonadReader r m, MonadIO m, MonadThrow m) => ShaderName -> m ShaderModule
- data Params = Params {
- title :: !Text
- mDeviceDescriptor :: !(SMaybe DeviceDescriptor)
- data Resources = Resources {}
- loadResources :: forall m. (MonadResource m, MonadThrow m) => Params -> m Resources
- data AppException
Swap Chain
Types
data SwapChainState Source #
Contains mutable state to manage the swap chain.
Functions
emptySwapChainState :: MonadResource m => m SwapChainState Source #
Initialize a new SwapChainState
.
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 #
Render Pipelines
Types
data RenderPipelineName Source #
Name of a render pipeline.
Instances
data RenderPipelines Source #
Container for mutable state that contains a map of render pipelines.
Functions
emptyRenderPipelines :: MonadResource m => m RenderPipelines Source #
Create an empty RenderPipelines
.
:: (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.
:: (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 ShaderName Source #
Name of a shader.
Instances
Eq ShaderName Source # | |
Defined in WGPU.BoneYard.SimpleSDL (==) :: ShaderName -> ShaderName -> Bool # (/=) :: ShaderName -> ShaderName -> Bool # | |
Ord ShaderName Source # | |
Defined in WGPU.BoneYard.SimpleSDL compare :: ShaderName -> ShaderName -> Ordering # (<) :: ShaderName -> ShaderName -> Bool # (<=) :: ShaderName -> ShaderName -> Bool # (>) :: ShaderName -> ShaderName -> Bool # (>=) :: ShaderName -> ShaderName -> Bool # max :: ShaderName -> ShaderName -> ShaderName # min :: ShaderName -> ShaderName -> ShaderName # | |
Show ShaderName Source # | |
Defined in WGPU.BoneYard.SimpleSDL showsPrec :: Int -> ShaderName -> ShowS # show :: ShaderName -> String # showList :: [ShaderName] -> ShowS # | |
IsString ShaderName Source # | |
Defined in WGPU.BoneYard.SimpleSDL fromString :: String -> ShaderName # |
Functions
emptyShaders :: MonadResource m => m Shaders Source #
Create an empty Shaders
.
:: (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
|
Compile a WGSL shader, adding it to the Shaders
map, and returning the
compiled ShaderModule
.
:: (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 |
Compile a WGSL shader, adding it to the Shaders
map.
:: (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
Parameters for initialization.
Params | |
|
Resources for the app.
Instances
Functions
:: forall m. (MonadResource m, MonadThrow m) | |
=> Params | Initialization parameters. |
-> m Resources | Created application resources. |
Exceptions
data AppException Source #
Exceptions from SimpleSDL.
AdapterRequestFailed | Requesting an adapter failed. |
DeviceRequestFailed | Requesting a device failed. |
UnknownShaderName ShaderName | Requesting a shader failed. |
UnknownRenderPipelineName RenderPipelineName | Requesting a render pipeline failed. |
Instances
Show AppException Source # | |
Defined in WGPU.BoneYard.SimpleSDL showsPrec :: Int -> AppException -> ShowS # show :: AppException -> String # showList :: [AppException] -> ShowS # | |
Exception AppException Source # | |
Defined in WGPU.BoneYard.SimpleSDL |