Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Renderer2 = Renderer (V2 Float) Float Raster
- data Context = Context {
- ctxFramebufferSize :: IO (Int, Int)
- ctxWindowSize :: IO (Int, Int)
- allocAndActivateTex :: GLenum -> IO GLuint
- initializeTexImage2D :: GLsizei -> GLsizei -> IO ()
- loadImage :: FilePath -> IO (Maybe (V2 Int, GLuint))
- maybeLoadTexture :: Either String DynamicImage -> IO (Maybe (V2 Int, GLuint))
- loadTexture :: DynamicImage -> IO (V2 Int, GLuint)
- loadTextureUnit :: Maybe GLuint -> DynamicImage -> IO (V2 Int, GLuint)
- unloadTexture :: GLuint -> IO ()
- loadImageAsTexture :: FilePath -> IO (Maybe GLuint)
- bindTexsAround :: MonadIO m => [GLuint] -> m a -> m a
- bindTexAround :: MonadIO m => GLuint -> m a -> m a
- colorPolylineRenderer :: Context -> Simple2DShader -> Float -> Float -> (LineCap, LineCap) -> Vector (V2 Float) -> Vector (V4 Float) -> IO Renderer2
- texPolylineRenderer :: Context -> Simple2DShader -> Float -> Float -> (LineCap, LineCap) -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2
- colorRenderer :: Context -> Simple2DShader -> GLuint -> Vector (V2 Float) -> Vector (V4 Float) -> IO Renderer2
- textureRenderer :: Context -> Simple2DShader -> GLuint -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2
- colorBezRenderer :: Context -> Simple2DShader -> Vector (V2 Float) -> Vector (V4 Float) -> IO Renderer2
- textureBezRenderer :: Context -> Simple2DShader -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2
- maskRenderer :: Context -> Simple2DShader -> GLuint -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2
- stencilMask :: IO () -> IO () -> IO ()
- alphaMask :: Context -> Simple2DShader -> IO () -> IO () -> IO Renderer2
- transformRenderer :: [RenderTransform2] -> Renderer2 -> Renderer2
- toTexture :: Context -> IO () -> IO GLuint
- toTextureUnit :: Maybe GLuint -> Context -> IO () -> IO GLuint
- clipTexture :: GLuint -> ClippingArea -> IO GLuint
Renderer
Loading and using textures
loadTexture :: DynamicImage -> IO (V2 Int, GLuint) Source #
loadTextureUnit :: Maybe GLuint -> DynamicImage -> IO (V2 Int, GLuint) Source #
unloadTexture :: GLuint -> IO () Source #
bindTexsAround :: MonadIO m => [GLuint] -> m a -> m a Source #
Binds the given textures to GL_TEXTURE0, GL_TEXTURE1, ... in ascending order of the texture unit, runs the IO action and then unbinds the textures.
bindTexAround :: MonadIO m => GLuint -> m a -> m a Source #
Line rendering
colorPolylineRenderer :: Context -> Simple2DShader -> Float -> Float -> (LineCap, LineCap) -> Vector (V2 Float) -> Vector (V4 Float) -> IO Renderer2 Source #
Creates and returns a renderer that renders a colored, expanded 2d polyline projected in 2d space.
texPolylineRenderer :: Context -> Simple2DShader -> Float -> Float -> (LineCap, LineCap) -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2 Source #
Creates and returns a renderer that renders a textured, expanded 2d polyline projected in 2d space.
Triangle rendering
colorRenderer :: Context -> Simple2DShader -> GLuint -> Vector (V2 Float) -> Vector (V4 Float) -> IO Renderer2 Source #
Creates and returns a renderer that renders the given colored geometry.
textureRenderer :: Context -> Simple2DShader -> GLuint -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2 Source #
Creates and returns a renderer that renders a textured geometry.
Bezier rendering
colorBezRenderer :: Context -> Simple2DShader -> Vector (V2 Float) -> Vector (V4 Float) -> IO Renderer2 Source #
Creates and returns a renderer that renders the given colored beziers.
textureBezRenderer :: Context -> Simple2DShader -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2 Source #
Creates and returns a renderer that renders the given textured beziers.
Masking
maskRenderer :: Context -> Simple2DShader -> GLuint -> Vector (V2 Float) -> Vector (V2 Float) -> IO Renderer2 Source #
Creates and returns a renderer that masks a textured rectangular area with another texture.
stencilMask :: IO () -> IO () -> IO () Source #
Creates an IO () drawing computation that masks an IO () drawing computation with another using a stencil test.
alphaMask :: Context -> Simple2DShader -> IO () -> IO () -> IO Renderer2 Source #
Creates a rendering that masks an IO () drawing computation with the alpha value of another.
Transforming a rendering
transformRenderer :: [RenderTransform2] -> Renderer2 -> Renderer2 Source #
Utils
clipTexture :: GLuint -> ClippingArea -> IO GLuint Source #
Sub-samples a texture using the given coordinate box and creates a new
texture. Keep in mind that OpenGL texture coordinates are flipped from
normal
graphics coordinates (y = 0 is the bottom of the texture). That
fact has bitten the author a number of times while clipping a texture
created with toTexture
and toUnitTexture
.