yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
metal_renderer.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <unordered_map>
6#include <vector>
7
8namespace yaze {
9namespace gfx {
10
11class MetalRenderer final : public IRenderer {
12 public:
13 MetalRenderer() = default;
14 ~MetalRenderer() override;
15
16 bool Initialize(SDL_Window* window) override;
17 void Shutdown() override;
18
19 TextureHandle CreateTexture(int width, int height) override;
20 TextureHandle CreateTextureWithFormat(int width, int height, uint32_t format,
21 int access) override;
22 void UpdateTexture(TextureHandle texture, const Bitmap& bitmap) override;
23 void DestroyTexture(TextureHandle texture) override;
24 bool LockTexture(TextureHandle texture, SDL_Rect* rect, void** pixels,
25 int* pitch) override;
26 void UnlockTexture(TextureHandle texture) override;
27
28 void Clear() override;
29 void Present() override;
30 void RenderCopy(TextureHandle texture, const SDL_Rect* srcrect,
31 const SDL_Rect* dstrect) override;
32 void SetRenderTarget(TextureHandle texture) override;
33 void SetDrawColor(SDL_Color color) override;
34 void* GetBackendRenderer() override;
35
36 void SetMetalView(void* view);
37
38 private:
40 std::vector<uint8_t> data;
41 int pitch = 0;
42 int width = 0;
43 int height = 0;
44 };
45
46 void* metal_view_ = nullptr;
47 void* command_queue_ = nullptr;
49 std::unordered_map<TextureHandle, StagingBuffer> staging_buffers_;
50};
51
52} // namespace gfx
53} // 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:60
void RenderCopy(TextureHandle texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect) override
Copies a portion of a texture to the current render target.
void Shutdown() override
Shuts down the renderer and releases all associated resources.
std::unordered_map< TextureHandle, StagingBuffer > staging_buffers_
TextureHandle CreateTexture(int width, int height) override
Creates a new, empty texture.
bool Initialize(SDL_Window *window) override
Initializes the renderer with a given window.
void SetMetalView(void *view)
void SetRenderTarget(TextureHandle texture) override
Sets the render target for subsequent drawing operations.
TextureHandle CreateTextureWithFormat(int width, int height, uint32_t format, int access) override
Creates a new texture with a specific pixel format.
void DestroyTexture(TextureHandle texture) override
Destroys a texture and frees its associated resources.
void UpdateTexture(TextureHandle texture, const Bitmap &bitmap) override
Updates a texture with the pixel data from a Bitmap.
void Present() override
Presents the back buffer to the screen, making the rendered content visible.
void UnlockTexture(TextureHandle texture) override
void * GetBackendRenderer() override
Provides an escape hatch to get the underlying, concrete renderer object.
void SetDrawColor(SDL_Color color) override
Sets the color used for drawing operations (e.g., Clear).
void Clear() override
Clears the entire render target with the current draw color.
bool LockTexture(TextureHandle texture, SDL_Rect *rect, void **pixels, int *pitch) override
void * TextureHandle
An abstract handle representing a texture.
Definition irenderer.h:47