← API Reference Class

asge::video::SDLRenderer final

A owing wrapper around SDL_Render.

#include <SDLRenderer.hpp>

Inherits from asge::video::IRenderer.

Inheritance

classDiagram
    class N2["asge::video::IRenderer"]
    class N1["asge::video::SDLRenderer"]
    N2 <|-- N1
    click N2 href "classasge_1_1video_1_1IRenderer.html"
    click N1 href "classasge_1_1video_1_1SDLRenderer.html"

Collaboration

classDiagram
    class N2["asge::video::IRenderer"]
    class N1["asge::video::SDLRenderer"]
    N2 <|-- N1
    click N2 href "classasge_1_1video_1_1IRenderer.html"
    click N1 href "classasge_1_1video_1_1SDLRenderer.html"

Private Attributes

#SDL_Renderer * m_Renderer {nullptr}private
#Camera m_Camera {}private
#Viewport m_Viewport {}private

Public Member Functions

#SDLRenderer(SDL_Window *inWindow)
#SDLRenderer(SDLRenderer &&inOther)
#SDLRenderer & operator=(SDLRenderer &&inOther)
#virtual ~SDLRenderer()
#SDLRenderer(SDLRenderer const &inOther)=delete
#SDLRenderer & operator=(SDLRenderer const &inOther)=delete
#virtual void Clear(graphics::RGBA_Color const &inColor) const override
Overrides Clear
#virtual void DrawRect(math::Rect const &inRect, graphics::RGBA_Color const &inColor, bool inFill) const override

Draw a rectangle to screen.

Draw a rectangle to screen given the input position (X, Y), the dimension (W = width, H = height) and the filling color (RGBA).

Overrides DrawRect
#virtual void DrawLine(math::Float2 const &inC1, math::Float2 const &inC2, graphics::RGBA_Color const &inColor) const override
Overrides DrawLine
#virtual void DrawCircle(math::Int2 const &inCenter, int inRadius, graphics::RGBA_Color const &inColor, bool inFill) const override

Draw a circle to screen.

Draws the outline (or filled interior) of a circle, rasterized via math::MidpointCirclePoints.

Overrides DrawCircle
#virtual void DrawTexture(ITexture const &inTexture, math::Rect const &inDestRect) const noexcept override

Draw a texture to screen, scaled into the given destination rect.

Parameters
inTexture

the texture to draw

inDestRect

the destination rectangle (position + size) to draw into

Overrides DrawTexture
#virtual void DrawTexture(ITexture const &inTexture, math::Float2 const &inPosition) const noexcept override

Draw a texture to screen at native size.

Draws the texture at the given position using its own width/height (from ITexture::Size()) — no scaling.

Parameters
inTexture

the texture to draw

inPosition

the top-left position to draw at

Overrides DrawTexture
#virtual void DrawTexture(ITexture const &inTexture, math::Rect const &inSrcRect, math::Rect const &inDestRect) const noexcept override

Draw a sub-region of a texture, scaled into the given destination rect.

Draws only the portion of inTexture within inSrcRect, stretched to fill inDestRect. Used for atlas-backed content (e.g. glyphs) where each draw call needs one small slice of a shared texture rather than the whole thing.

Parameters
inTexture

the texture to draw from

inSrcRect

the source rectangle within inTexture, in pixels

inDestRect

the destination rectangle (position + size) to draw into

Overrides DrawTexture
#virtual void DrawTextureTiled(ITexture const &inTexture, float inScale, math::Rect const &inDestRect) const noexcept override

Draw a texture repeated (tiled) to fill a destination rectangle.

Instead of stretching the source texture to fit, repeats it like a wallpaper pattern, clipped to inDestRect. Typical use: backgrounds, tilemaps, scrolling layers.

Parameters
inTexture

the texture to draw

inScale

scale applied to each tile before repeating (1.0 = native size)

inDestRect

the destination rectangle to fill

#virtual void DrawTextureAffine(ITexture const &inTexture, math::Float2 const &inOrigin, math::Float2 const &inRight, math::Float2 const &inDown) const noexcept override

Draw a texture using an arbitrary affine transform.

Maps the texture's (0,0)/(w,0)/(0,h) corners to inOrigin/inRight/inDown on screen. Supports rotation, shear, and non-uniform scale in one call.

Parameters
inTexture

the texture to draw

inOrigin

where the texture's top-left (0,0) lands on screen

inRight

where the texture's top-right (w,0) lands on screen

inDown

where the texture's bottom-left (0,h) lands on screen

#virtual void DrawTextureAffine(ITexture const &inTexture, math::Rect const &inSrcRect, math::Float2 const &inOrigin, math::Float2 const &inRight, math::Float2 const &inDown) const noexcept override

Draw a sub-region of a texture using an arbitrary affine transform.

Same mapping as the whole-texture DrawTextureAffine overload, except inOrigin/inRight/inDown correspond to inSrcRect's own top-left/ top-right/bottom-left corners rather than the whole texture's — needed to draw a rotated sprite cropped to one cell of a larger spritesheet (e.g. an animation frame).

Parameters
inTexture

the texture to draw from

inSrcRect

the source rectangle within inTexture, in pixels

inOrigin

where inSrcRect's top-left corner lands on screen

inRight

where inSrcRect's top-right corner lands on screen

inDown

where inSrcRect's bottom-left corner lands on screen

#virtual void DrawTexture9Grid(ITexture const &inTexture, float inLeft, float inRight, float inTop, float inBottom, math::Rect const &inDestRect) const noexcept override

Draw a texture using nine-slice (9-grid) scaling.

Splits the texture into a 3x3 grid using the given margins. Corners are drawn unscaled, edges stretch along one axis, and the center stretches to fill the remaining space — keeps borders/corners crisp regardless of destination size. Typical use: UI panels, buttons, dialog boxes.

Parameters
inTexture

the texture to draw

inLeft

width of the left margin, in texture pixels

inRight

width of the right margin, in texture pixels

inTop

height of the top margin, in texture pixels

inBottom

height of the bottom margin, in texture pixels

inDestRect

the destination rectangle to fill

#virtual void DrawString(str::StringView inText, media::Font const &inFont, ITexture &inTexture, math::Float2 const &inPosition, graphics::RGBA_Color const &inColor) const noexcept override

Draw a string of text using a baked Font and its uploaded atlas texture.

Renders characters from a fixed baked ASCII range (see Font::Load). Codepoints outside that range are skipped. Tints the shared atlas texture via inTexture's color mod before drawing, so all glyphs in this call share inColor.

Parameters
inFont

the loaded font providing glyph metrics

inTexture

the atlas texture uploaded from inFont.GetAtlasImage()

inText

the text to draw

inPosition

the baseline-relative pen start position

inColor

tint applied to the (alpha-only) atlas glyphs

Overrides DrawString
#virtual std::unique_ptr< ITexture > CreateTexture(media::Image const &inImage) const noexcept override
Overrides CreateTexture
#virtual void Present() const override
Overrides Present
#virtual bool IsValid() const override
Overrides IsValid
#virtual void * NativeHandle() const noexcept override
Overrides NativeHandle
#virtual void SetCamera(Camera const &inCamera) override

Sets the camera every subsequent draw call is transformed through.

Every draw call (DrawRect, DrawTexture*, DrawLine, DrawCircle, ...) maps its world-space coordinates to screen space via inCamera before rendering see Camera.hpp's WorldToScreen/TransformRect.

Overrides SetCamera
#virtual Camera const & GetCamera() const override
Overrides GetCamera
#virtual void SetViewport(Viewport const &inViewport) override

Sets the screen-space viewport draw calls are clipped/offset into.

Backed by the native renderer's own viewport support (e.g. SDL_SetRenderViewport), so clipping outside inViewport is handled by the backend rather than by this class.

Overrides SetViewport
#virtual Viewport const & GetViewport() const override
Overrides GetViewport
#void Destroy()