HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulesdl2-2.5.5.0Haskell2010

SDL.Video.Renderer

SDL.Video.Renderer provides a high-level interface to SDL's accelerated 2D rendering library.

  • 14 types
  • 72 values
  • Packagesdl2-2.5.5.0
  • Exports86
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceRenderer.hs
newtypenewtype Renderer
#

An SDL rendering device. This can be created with createRenderer.

Instances6Eq, Data, Ord, Show, Generic, Rep

Renderer Configuration

3 declarations

These configuration options can be used with createRenderer to create Renderers.

datadata RendererConfig
#

The configuration data used when creating windows.

Constructors

Instances9Eq, Data, Ord, Read, Show, Generic, …
datadata RendererType
#

Renderer acceleration mode

Constructors

Instances9Bounded, Enum, Eq, Data, Ord, Read, …

Drawing Primitives

25 declarations
valuecopyEx
  1. :: MonadIO m
  2. => Renderer

    The rendering context

  3. -> Texture

    The source texture

  4. -> Maybe (Rectangle CInt)

    The source rectangle to copy, or Nothing for the whole texture

  5. -> Maybe (Rectangle CInt)

    The destination rectangle to copy to, or Nothing for the whole rendering target. The texture will be stretched to fill the given rectangle.

  6. -> CDouble

    The angle of rotation in degrees. The rotation will be performed clockwise.

  7. -> Maybe (Point V2 CInt)

    The point indicating the center of the rotation, or Nothing to rotate around the center of the destination rectangle

  8. -> V2 Bool

    Whether to flip the texture on the X and/or Y axis

  9. -> m ()
#

Copy a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right.

See SDL_RenderCopyEx for C documentation.

valuecopyExF
  1. :: MonadIO m
  2. => Renderer

    The rendering context

  3. -> Texture

    The source texture

  4. -> Maybe (Rectangle CInt)

    The source rectangle to copy, or Nothing for the whole texture

  5. -> Maybe (Rectangle CFloat)

    The destination rectangle to copy to, or Nothing for the whole rendering target. The texture will be stretched to fill the given rectangle.

  6. -> CDouble

    The angle of rotation in degrees. The rotation will be performed clockwise.

  7. -> Maybe (Point V2 CFloat)

    The point indicating the center of the rotation, or Nothing to rotate around the center of the destination rectangle

  8. -> V2 Bool

    Whether to flip the texture on the X and/or Y axis

  9. -> m ()
#

Copy a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right.

valuepresent :: MonadIO m => Renderer -> m ()
#

Update the screen with any rendering performed since the previous call.

SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as drawLine does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and present the composed backbuffer to the screen as a complete picture.

Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.

The backbuffer should be considered invalidated after each present; do not assume that previous contents will exist between frames. You are strongly encouraged to call clear to initialize the backbuffer before starting each new frame's drawing, even if you plan to overwrite every pixel.

See SDL_RenderPresent for C documentation.

Renderer State

8 declarations

SDL exposes a stateful interface to Renderers - the above primitives drawing routines will change their output depending on the value of these state variables.

Get or set the drawing scale for rendering on the current target.

The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.

If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.

See SDL_RenderSetScale and SDL_RenderGetScale for C documentation.

Surfaces

6 declarations
valuesurfaceFillRect
  1. :: MonadIO m
  2. => Surface

    The Surface that is the drawing target.

  3. -> Maybe (Rectangle CInt)

    The rectangle to fill, or Nothing to fill the entire surface.

  4. -> V4 Word8

    The color to fill with. If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place. This colour will be implictly mapped to the closest approximation that matches the surface's pixel format.

  5. -> m ()
#

Perform a fast fill of a rectangle with a specific color.

If there is a clip rectangle set on the destination (set via clipRect), then this function will fill based on the intersection of the clip rectangle and the given Rectangle.

See SDL_FillRect for C documentation.

valuesurfaceFillRects
  1. :: MonadIO m
  2. => Surface

    The Surface that is the drawing target.

  3. -> Vector (Rectangle CInt)

    A Vector of Rectangles to be filled.

  4. -> V4 Word8

    The color to fill with. If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place. This colour will be implictly mapped to the closest approximation that matches the surface's pixel format.

  5. -> m ()
#

Perform a fast fill of a set of rectangles with a specific color.

If there is a clip rectangle set on any of the destinations (set via clipRect), then this function will fill based on the intersection of the clip rectangle and the given Rectangles.

See SDL_FillRects for C documentation.

Creating and Destroying Surfaces

valueconvertSurface
  1. :: (Functor m, MonadIO m)
  2. => Surface

    The Surface to convert

  3. -> SurfacePixelFormat

    The pixel format that the new surface is optimized for

  4. -> m Surface
#

Copy an existing surface into a new one that is optimized for blitting to a surface of a specified pixel format.

This function is used to optimize images for faster repeat blitting. This is accomplished by converting the original and storing the result as a new surface. The new, optimized surface can then be used as the source for future blits, making them faster.

See SDL_ConvertSurface for C documentation.

Surface state

Accessing Surface Data

Palettes and pixel formats

10 declarations
newtypenewtype Palette
#
Instances1Eq
  • Eq PaletteDefined in sdl2-2.5.5.0 · SDL.Video.Renderer
datadata PixelFormat
#
Instances9Eq, Data, Ord, Read, Show, Generic, …

Textures

1 declaration
newtypenewtype Texture
#
Instances1Eq
  • Eq TextureDefined in sdl2-2.5.5.0 · SDL.Video.Renderer

Creating, Using and Destroying Textures

datadata TextureAccess
#

Information to the GPU about how you will use a texture.

Constructors

Instances11Bounded, Enum, Eq, Data, Ord, Read, …
valueglBindTexture
  1. :: (Functor m, MonadIO m)
  2. => Texture

    The texture to bind to the current OpenGL/ES/ES2 context

  3. -> m ()
#

Bind an OpenGL/ES/ES2 texture to the current context for use with when rendering OpenGL primitives directly.

See SDL_GL_BindTexture for C documentation.

Texture State

datadata BlendMode
#

Blend modes used in copy and drawing operations.

Constructors

  • BlendNone

    No blending

  • BlendAlphaBlend

    Alpha blending.

    dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
    dstA = srcA + (dstA * (1-srcA))
    
  • BlendAdditive

    Additive blending

    dstRGB = (srcRGB * srcA) + dstRGB
    dstA = dstA
    
  • BlendMod

    Color modulate

    @ dstRGB = srcRGB * dstRGB dstA = dstA

Instances11Bounded, Enum, Eq, Data, Ord, Read, …

Accessing Texture Data

datadata TextureInfo
#

Constructors

Instances6Eq, Ord, Read, Show, Generic, Rep
datadata Rectangle a
#

Constructors

Instances8Functor, Eq, Ord, Read, Show, Generic, …

Available Renderers

3 declarations

These functions allow you to query the current system for available Renderers that can be created with createRenderer.

datadata RendererInfo
#

Information about an instantiated Renderer.

Constructors

Instances6Eq, Ord, Read, Show, Generic, Rep