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 CreateRenderTargetTexture(int width, int height) override;
43 TextureHandle CreateTextureWithFormat(int width, int height, uint32_t format,
44 int access) override;
45 void UpdateTexture(TextureHandle texture, const Bitmap& bitmap) override;
46 void DestroyTexture(TextureHandle texture) override;
47
48 // --- Direct Pixel Access ---
49 bool LockTexture(TextureHandle texture, SDL_Rect* rect, void** pixels,
50 int* pitch) override;
51 void UnlockTexture(TextureHandle texture) override;
52
53 // --- Rendering Primitives ---
54 void Clear() override;
55 void Present() override;
56 void RenderCopy(TextureHandle texture, const SDL_Rect* srcrect,
57 const SDL_Rect* dstrect) override;
58 void SetRenderTarget(TextureHandle texture) override;
59 void SetDrawColor(SDL_Color color) override;
60
65 void* GetBackendRenderer() override { return renderer_; }
66
67 private:
74 static SDL_FRect* ToFRect(const SDL_Rect* rect, SDL_FRect* frect);
75
76 // The core SDL3 renderer object.
77 // Unlike SDL2Renderer, we don't use a custom deleter because SDL3 has
78 // different cleanup semantics and we want explicit control over shutdown.
79 SDL_Renderer* renderer_ = nullptr;
80};
81
82} // namespace gfx
83} // namespace yaze
84
85#endif // YAZE_USE_SDL3
86
87#endif // YAZE_APP_GFX_BACKEND_SDL3_RENDERER_H_
void Clear()
Clear all context state.
void * TextureHandle
An abstract handle representing a texture.
Definition irenderer.h:47