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
3#include <SDL.h>
4#include <memory>
5#include <vector>
6
7// Forward declarations prevent circular dependencies and speed up compilation.
8// Instead of including the full header, we just tell the compiler that these types exist.
9namespace yaze {
10namespace gfx {
11class Bitmap;
12}
13}
14
15namespace yaze {
16namespace gfx {
17
24using TextureHandle = void*;
25
35class IRenderer {
36public:
37 virtual ~IRenderer() = default;
38
39 // --- Initialization and Lifecycle ---
40
46 virtual bool Initialize(SDL_Window* window) = 0;
47
51 virtual void Shutdown() = 0;
52
53 // --- Texture Management ---
54
61 virtual TextureHandle CreateTexture(int width, int height) = 0;
62
71 virtual TextureHandle CreateTextureWithFormat(int width, int height, uint32_t format, int access) = 0;
72
78 virtual void UpdateTexture(TextureHandle texture, const Bitmap& bitmap) = 0;
79
84 virtual void DestroyTexture(TextureHandle texture) = 0;
85
86 // --- Direct Pixel Access ---
87 virtual bool LockTexture(TextureHandle texture, SDL_Rect* rect, void** pixels, int* pitch) = 0;
88 virtual void UnlockTexture(TextureHandle texture) = 0;
89
90 // --- Rendering Primitives ---
91
95 virtual void Clear() = 0;
96
100 virtual void Present() = 0;
101
108 virtual void RenderCopy(TextureHandle texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect) = 0;
109
114 virtual void SetRenderTarget(TextureHandle texture) = 0;
115
120 virtual void SetDrawColor(SDL_Color color) = 0;
121
122 // --- Backend-specific Access ---
123
133 virtual void* GetBackendRenderer() = 0;
134};
135
136} // namespace gfx
137} // namespace yaze
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:66
Defines an abstract interface for all rendering operations.
Definition irenderer.h:35
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:24
Main namespace for the application.