yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
renderer_factory.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GFX_BACKEND_RENDERER_FACTORY_H_
2#define YAZE_APP_GFX_BACKEND_RENDERER_FACTORY_H_
3
4#include <memory>
5
6#if defined(__APPLE__)
7#include <TargetConditionals.h>
8#endif
9
12
13#ifdef YAZE_USE_SDL3
15#endif
16
17#if defined(__APPLE__)
19#endif
20
21namespace yaze {
22namespace gfx {
23
29 SDL2,
30 SDL3,
31 Metal,
32 kDefault,
34};
35
55 public:
65 static std::unique_ptr<IRenderer> Create(
67 switch (type) {
69#ifndef YAZE_USE_SDL3
70 return std::make_unique<SDL2Renderer>();
71#else
72 return nullptr;
73#endif
74
76#ifdef YAZE_USE_SDL3
77 return std::make_unique<SDL3Renderer>();
78#else
79 // SDL3 not available in this build, fall back to SDL2
80 return std::make_unique<SDL2Renderer>();
81#endif
82
84#if defined(__APPLE__)
85 return std::make_unique<MetalRenderer>();
86#else
87 return nullptr;
88#endif
89
92 default:
93 // Use the default backend based on build configuration
94#if defined(__APPLE__) && (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
95 return std::make_unique<MetalRenderer>();
96#elif defined(YAZE_USE_SDL3)
97 return std::make_unique<SDL3Renderer>();
98#else
99 return std::make_unique<SDL2Renderer>();
100#endif
101 }
102 }
103
111 switch (type) {
113 // SDL2 is always available (base requirement)
114 return true;
115
117#ifdef YAZE_USE_SDL3
118 return true;
119#else
120 return false;
121#endif
122
124#if defined(__APPLE__)
125 return true;
126#else
127 return false;
128#endif
129
132 // Default/auto-detect is always available
133 return true;
134
135 default:
136 return false;
137 }
138 }
139
146 static const char* GetBackendName(RendererBackendType type) {
147 switch (type) {
149 return "SDL2";
151 return "SDL3";
153 return "Metal";
155 return "Default";
157 return "AutoDetect";
158 default:
159 return "Unknown";
160 }
161 }
162
169#if defined(__APPLE__) && (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
171#elif defined(YAZE_USE_SDL3)
173#else
175#endif
176 }
177};
178
179} // namespace gfx
180} // namespace yaze
181
182#endif // YAZE_APP_GFX_BACKEND_RENDERER_FACTORY_H_
Factory class for creating IRenderer instances.
static RendererBackendType GetDefaultBackendType()
Get the default backend type for this build.
static std::unique_ptr< IRenderer > Create(RendererBackendType type=RendererBackendType::kDefault)
Create a renderer instance with the specified backend type.
static const char * GetBackendName(RendererBackendType type)
Get a string name for a backend type.
static bool IsBackendAvailable(RendererBackendType type)
Check if a specific backend type is available in this build.
RendererBackendType
Enumeration of available rendering backend types.
@ SDL3
SDL3 renderer backend.
@ SDL2
SDL2 renderer backend.
@ kAutoDetect
Automatically select the best available backend.
@ kDefault
Use the default backend based on build configuration.
@ Metal
Metal renderer backend (Apple platforms)