yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
irenderer.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <memory>
6#include <vector>
7
8// Forward declarations prevent circular dependencies and speed up compilation.
9// Instead of including the full header, we just tell the compiler that these
10// types exist.
11namespace yaze {
12namespace gfx {
13class Bitmap;
14}
15} // namespace yaze
16
17namespace yaze {
18namespace gfx {
19
27using TextureHandle = void*;
28
40class IRenderer {
41 public:
42 virtual ~IRenderer() = default;
43
44 // --- Initialization and Lifecycle ---
45
51 virtual bool Initialize(SDL_Window* window) = 0;
52
56 virtual void Shutdown() = 0;
57
58 // --- Texture Management ---
59
67 virtual TextureHandle CreateTexture(int width, int height) = 0;
68
79 virtual TextureHandle CreateTextureWithFormat(int width, int height,
80 uint32_t format,
81 int access) = 0;
82
88 virtual void UpdateTexture(TextureHandle texture, const Bitmap& bitmap) = 0;
89
94 virtual void DestroyTexture(TextureHandle texture) = 0;
95
96 // --- Direct Pixel Access ---
97 virtual bool LockTexture(TextureHandle texture, SDL_Rect* rect, void** pixels,
98 int* pitch) = 0;
99 virtual void UnlockTexture(TextureHandle texture) = 0;
100
101 // --- Rendering Primitives ---
102
106 virtual void Clear() = 0;
107
112 virtual void Present() = 0;
113
122 virtual void RenderCopy(TextureHandle texture, const SDL_Rect* srcrect,
123 const SDL_Rect* dstrect) = 0;
124
130 virtual void SetRenderTarget(TextureHandle texture) = 0;
131
136 virtual void SetDrawColor(SDL_Color color) = 0;
137
138 // --- Backend-specific Access ---
139
151 virtual void* GetBackendRenderer() = 0;
152};
153
154} // namespace gfx
155} // namespace yaze
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
Defines an abstract interface for all rendering operations.
Definition irenderer.h:40
virtual void UnlockTexture(TextureHandle texture)=0
virtual TextureHandle CreateTexture(int width, int height)=0
Creates a new, empty texture.
virtual bool Initialize(SDL_Window *window)=0
Initializes the renderer with a given window.
virtual void * GetBackendRenderer()=0
Provides an escape hatch to get the underlying, concrete renderer object.
virtual void UpdateTexture(TextureHandle texture, const Bitmap &bitmap)=0
Updates a texture with the pixel data from a Bitmap.
virtual bool LockTexture(TextureHandle texture, SDL_Rect *rect, void **pixels, int *pitch)=0
virtual ~IRenderer()=default
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 SetDrawColor(SDL_Color color)=0
Sets the color used for drawing operations (e.g., Clear).
virtual void Shutdown()=0
Shuts down the renderer and releases all associated resources.
virtual void Present()=0
Presents the back buffer to the screen, making the rendered content visible.
virtual void Clear()=0
Clears the entire render target with the current draw color.
virtual void DestroyTexture(TextureHandle texture)=0
Destroys a texture and frees its associated resources.
virtual TextureHandle CreateTextureWithFormat(int width, int height, uint32_t format, int access)=0
Creates a new texture with a specific pixel format.
virtual void SetRenderTarget(TextureHandle texture)=0
Sets the render target for subsequent drawing operations.
void * TextureHandle
An abstract handle representing a texture.
Definition irenderer.h:27
SDL2/SDL3 compatibility layer.