yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sdl3_renderer.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GFX_BACKEND_SDL3_RENDERER_H_
2#define YAZE_APP_GFX_BACKEND_SDL3_RENDERER_H_
3
4#ifdef YAZE_USE_SDL3
5
6#include <SDL3/SDL.h>
7
8#include <memory>
9
11
12namespace yaze {
13namespace gfx {
14
31class SDL3Renderer : public IRenderer {
32 public:
33 SDL3Renderer();
34 ~SDL3Renderer() override;
35
36 // --- Lifecycle and Initialization ---
37 bool Initialize(SDL_Window* window) override;
38 void Shutdown() override;
39
40 // --- Texture Management ---
41 TextureHandle CreateTexture(int width, int height) override;
42 TextureHandle CreateTextureWithFormat(int width, int height, uint32_t format,
43 int access) override;
44 void UpdateTexture(TextureHandle texture, const Bitmap& bitmap) override;
45 void DestroyTexture(TextureHandle texture) override;
46
47 // --- Direct Pixel Access ---
48 bool LockTexture(TextureHandle texture, SDL_Rect* rect, void** pixels,
49 int* pitch) override;
50 void UnlockTexture(TextureHandle texture) override;
51
52 // --- Rendering Primitives ---
53 void Clear() override;
54 void Present() override;
55 void RenderCopy(TextureHandle texture, const SDL_Rect* srcrect,
56 const SDL_Rect* dstrect) override;
57 void SetRenderTarget(TextureHandle texture) override;
58 void SetDrawColor(SDL_Color color) override;
59
64 void* GetBackendRenderer() override { return renderer_; }
65
66 private:
73 static SDL_FRect* ToFRect(const SDL_Rect* rect, SDL_FRect* frect);
74
75 // The core SDL3 renderer object.
76 // Unlike SDL2Renderer, we don't use a custom deleter because SDL3 has
77 // different cleanup semantics and we want explicit control over shutdown.
78 SDL_Renderer* renderer_ = nullptr;
79};
80
81} // namespace gfx
82} // namespace yaze
83
84#endif // YAZE_USE_SDL3
85
86#endif // YAZE_APP_GFX_BACKEND_SDL3_RENDERER_H_
void * TextureHandle
An abstract handle representing a texture.
Definition irenderer.h:27