asge::video
Classes & Structs
Camera
Struct
IRenderer
Class
ITexture
Class
IWindow
Class
SDLRenderer
Class
SDLTexture
Class
SDLUploadBuffer
Struct
SDLWindow
Class
VideoSystem
Class
Enumerations
enum class GraphicsBackend : std::uint8_tSDLTypedefs
using Viewport = math::RectFunctions
math::Float2 WorldToScreen(Camera const &inCamera, math::Float2 inWorldPos) noexceptConverts a world-space point to screen space via inCamera's position and zoom.
math::Float2 WorldToScreen(Camera const &inCamera, Viewport const &inViewport, math::Float2 inWorldPos) noexceptConverts a world-space point to screen space, offsetting by inViewport's origin.
Viewport clipping is already handled by the renderer backend this only adds inViewport's (x, y) so the camera is anchored within it.
math::Float2 ScreenToWorld(Camera const &inCamera, Viewport const &inViewport, math::Float2 inScreenPos) noexceptmath::Rect TransformRect(Camera const &inCamera, math::Rect const &inWorldRect) noexceptmath::Rect VisibleWorldRect(Camera const &inCamera, Viewport const &inViewport) noexceptThe world-space rect currently visible through inViewport at inCamera's position/zoom.
Inverse of TransformRect's size math: inViewport's size divided by zoom gives how much world-space area is on screen, anchored at the camera's own (m_X, m_Y). Used by systems::RenderSystem to cull sprites whose destination rect doesn't overlap it at all, rather than drawing (and having the backend clip) every entity in the world every frame.
BoolResult InitializeBackend(GraphicsBackend inBackend)Initializes the given graphics backend's subsystem.
Must be called once before CreateWindow/CreateRenderer for that backend, and paired with a matching ShutdownBackend call.
inBackend | The graphics backend to initialize |
void ShutdownBackend(GraphicsBackend inBackend)Shuts down the given graphics backend's subsystem.
inBackend | The graphics backend to shut down |
std::unique_ptr< IWindow > CreateWindow(GraphicsBackend inBackend, std::string const &inTitle, int inWidth, int inHeight, bool inResizable)Creates a window for the given graphics backend.
inBackend | The graphics backend to create the window for |
inTitle | The title of the window |
inWidth | The width of the window |
inHeight | The height of the window |
inResizable | Whether the window can be resized by the user |
Creates a renderer for the given graphics backend, bound to the input window.
inBackend | The graphics backend to create the renderer for |
inWindow | The window the renderer will draw to |
void DrawTextureAnchored(IRenderer const &inRenderer, ITexture const &inTexture, math::Rect const &inSrcRect, math::Rect const &inDestRect, math::Float2 const &inSrcAnchor=math::Float2{ 0.0f, 0.0f }) noexceptDraws inSrcRect anchored at a normalized point within it, so that point (not inDestRect's top-left corner) lands at inDestRect's (x, y) — {0,0} reproduces plain DrawTexture(srcRect, destRect).
Lets one fixed anchor stay put on screen while inSrcRect's size varies call to call (e.g. differently-cropped animation frames).
SDL_PixelFormat MapPixelFormat(graphics::PixelFormat inFormat) noexceptMaps an asge::graphics::PixelFormat to the SDL_PixelFormat SDLTexture uploads as.
SDLUploadBuffer ExpandPixelsForUpload(media::Image const &inImage)Converts an Image's pixel bytes into the layout MapPixelFormat's return value expects.
RGBA8 images pass through unchanged. A8 images are expanded one byte into four: RGB set to white, alpha set to the source byte the standard trick for uploading single-channel glyph/mask data as a normal alpha-blended RGBA texture, tinted via SDL_SetTextureColorMod by the caller.