yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
window_backend_factory.cc
Go to the documentation of this file.
1// window_backend_factory.cc - Window Backend Factory Implementation
2
4
6#include "util/log.h"
7
8#if defined(__APPLE__)
9#include <TargetConditionals.h>
10#endif
11
12#if defined(__APPLE__) && (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
14#endif
15
16#ifdef YAZE_USE_SDL3
18#endif
19
20namespace yaze {
21namespace platform {
22
23std::unique_ptr<IWindowBackend> WindowBackendFactory::Create(
24 WindowBackendType type) {
25 switch (type) {
27#ifndef YAZE_USE_SDL3
28 return std::make_unique<SDL2WindowBackend>();
29#else
30 LOG_WARN("WindowBackendFactory",
31 "SDL2 backend requested but built with SDL3, using SDL3");
32 return std::make_unique<SDL3WindowBackend>();
33#endif
34
36#ifdef YAZE_USE_SDL3
37 return std::make_unique<SDL3WindowBackend>();
38#else
39 LOG_WARN("WindowBackendFactory",
40 "SDL3 backend requested but not available, using SDL2");
41 return std::make_unique<SDL2WindowBackend>();
42#endif
43
45#if defined(__APPLE__) && (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
46 return std::make_unique<IOSWindowBackend>();
47#else
48 LOG_WARN("WindowBackendFactory",
49 "iOS backend requested on non-iOS platform");
50 return nullptr;
51#endif
52
54 default:
55 return Create(GetDefaultType());
56 }
57}
58
60#if defined(__APPLE__) && (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
62#endif
63#ifdef YAZE_USE_SDL3
65#else
67#endif
68}
69
71 switch (type) {
73#ifdef YAZE_USE_SDL3
74 return false; // Built with SDL3, SDL2 not available
75#else
76 return true;
77#endif
78
80#ifdef YAZE_USE_SDL3
81 return true;
82#else
83 return false; // SDL3 not built in
84#endif
85
87 return true; // Auto always available
88
90#if defined(__APPLE__) && (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
91 return true;
92#else
93 return false;
94#endif
95
96 default:
97 return false;
98 }
99}
100
101} // namespace platform
102} // namespace yaze
static WindowBackendType GetDefaultType()
Get the default backend type for this build.
static std::unique_ptr< IWindowBackend > Create(WindowBackendType type)
Create a window backend of the specified type.
static bool IsAvailable(WindowBackendType type)
Check if a backend type is available.
#define LOG_WARN(category, format,...)
Definition log.h:107
WindowBackendType
Backend type enumeration for factory.
Definition iwindow.h:272