Defines an abstract interface for all rendering operations. More...
#include <irenderer.h>
Public Member Functions | |
virtual | ~IRenderer ()=default |
virtual bool | Initialize (SDL_Window *window)=0 |
Initializes the renderer with a given window. | |
virtual void | Shutdown ()=0 |
Shuts down the renderer and releases all associated resources. | |
virtual TextureHandle | CreateTexture (int width, int height)=0 |
Creates a new, empty texture. | |
virtual TextureHandle | CreateTextureWithFormat (int width, int height, uint32_t format, int access)=0 |
Creates a new texture with a specific pixel format. | |
virtual void | UpdateTexture (TextureHandle texture, const Bitmap &bitmap)=0 |
Updates a texture with the pixel data from a Bitmap. | |
virtual void | DestroyTexture (TextureHandle texture)=0 |
Destroys a texture and frees its associated resources. | |
virtual bool | LockTexture (TextureHandle texture, SDL_Rect *rect, void **pixels, int *pitch)=0 |
virtual void | UnlockTexture (TextureHandle texture)=0 |
virtual void | Clear ()=0 |
Clears the entire render target with the current draw color. | |
virtual void | Present ()=0 |
Presents the back buffer to the screen, making the rendered content visible. | |
virtual void | RenderCopy (TextureHandle texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect)=0 |
Copies a portion of a texture to the current render target. | |
virtual void | SetRenderTarget (TextureHandle texture)=0 |
Sets the render target for subsequent drawing operations. | |
virtual void | SetDrawColor (SDL_Color color)=0 |
Sets the color used for drawing operations (e.g., Clear). | |
virtual void * | GetBackendRenderer ()=0 |
Provides an escape hatch to get the underlying, concrete renderer object. | |
Defines an abstract interface for all rendering operations.
This interface decouples the application from any specific rendering API (like SDL2, SDL3, OpenGL, etc.). It provides a contract for creating textures, managing their lifecycle, and performing primitive drawing operations. The goal is to program against this interface, allowing the concrete rendering backend to be swapped out with minimal changes to the application code.
Definition at line 35 of file irenderer.h.
|
virtualdefault |
|
pure virtual |
Initializes the renderer with a given window.
window | A pointer to the SDL_Window to render into. |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::core::CreateWindow().
|
pure virtual |
Shuts down the renderer and releases all associated resources.
Implemented in yaze::gfx::SDL2Renderer.
|
pure virtual |
Creates a new, empty texture.
width | The width of the texture in pixels. |
height | The height of the texture in pixels. |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::AtlasRenderer::CreateNewAtlas(), and yaze::gfx::Arena::ProcessTextureQueue().
|
pure virtual |
Creates a new texture with a specific pixel format.
width | The width of the texture in pixels. |
height | The height of the texture in pixels. |
format | The SDL pixel format (e.g., SDL_PIXELFORMAT_ARGB8888). |
access | The texture access pattern (e.g., SDL_TEXTUREACCESS_STREAMING). |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::emu::Emulator::Run().
|
pure virtual |
Updates a texture with the pixel data from a Bitmap.
texture | The handle of the texture to update. |
bitmap | The Bitmap containing the new pixel data. |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::Arena::ProcessTextureQueue().
|
pure virtual |
Destroys a texture and frees its associated resources.
texture | The handle of the texture to destroy. |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::AtlasRenderer::Clear(), and yaze::gfx::Arena::ProcessTextureQueue().
|
pure virtual |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::emu::Emulator::Run(), and yaze::gui::DungeonObjectEmulatorPreview::TriggerEmulatedRender().
|
pure virtual |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::emu::Emulator::Run(), and yaze::gui::DungeonObjectEmulatorPreview::TriggerEmulatedRender().
|
pure virtual |
Clears the entire render target with the current draw color.
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::AtlasRenderer::RebuildAtlas().
|
pure virtual |
Presents the back buffer to the screen, making the rendered content visible.
Implemented in yaze::gfx::SDL2Renderer.
|
pure virtual |
Copies a portion of a texture to the current render target.
texture | The source texture handle. |
srcrect | A pointer to the source rectangle, or nullptr for the entire texture. |
dstrect | A pointer to the destination rectangle, or nullptr for the entire render target. |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::AtlasRenderer::AddBitmap(), yaze::gfx::AtlasRenderer::RebuildAtlas(), yaze::gfx::AtlasRenderer::RenderBatch(), yaze::gfx::AtlasRenderer::RenderBatchWithBppOptimization(), and yaze::gfx::AtlasRenderer::RenderBitmap().
|
pure virtual |
Sets the render target for subsequent drawing operations.
texture | The texture to set as the render target, or nullptr to set it back to the default (the window). |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::AtlasRenderer::AddBitmap(), and yaze::gfx::AtlasRenderer::RebuildAtlas().
|
pure virtual |
Sets the color used for drawing operations (e.g., Clear).
color | The SDL_Color to use. |
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::gfx::AtlasRenderer::RebuildAtlas().
|
pure virtual |
Provides an escape hatch to get the underlying, concrete renderer object.
This is necessary for integrating with third-party libraries like ImGui that are tied to a specific rendering backend (e.g., SDL_Renderer*, ID3D11Device*).
Implemented in yaze::gfx::SDL2Renderer.
Referenced by yaze::core::CreateWindow().