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
7#include "util/log.h"
8
9#if defined(__APPLE__)
10#include <TargetConditionals.h>
11#endif
12
13#if defined(__APPLE__) && \
14 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
16#endif
17
18#ifdef YAZE_USE_SDL3
20#endif
21
22namespace yaze {
23namespace platform {
24
25std::unique_ptr<IWindowBackend> WindowBackendFactory::Create(
26 WindowBackendType type) {
27 switch (type) {
29#ifndef YAZE_USE_SDL3
30 return std::make_unique<SDL2WindowBackend>();
31#else
32 LOG_WARN("WindowBackendFactory",
33 "SDL2 backend requested but built with SDL3, using SDL3");
34 return std::make_unique<SDL3WindowBackend>();
35#endif
36
38#ifdef YAZE_USE_SDL3
39 return std::make_unique<SDL3WindowBackend>();
40#else
41 LOG_WARN("WindowBackendFactory",
42 "SDL3 backend requested but not available, using SDL2");
43 return std::make_unique<SDL2WindowBackend>();
44#endif
45
47 LOG_WARN("WindowBackendFactory",
48 "GLFW backend requested but not implemented yet, using default "
49 "backend");
50 return Create(GetDefaultType());
51
53#if defined(__APPLE__) && \
54 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
55 return std::make_unique<IOSWindowBackend>();
56#else
57 LOG_WARN("WindowBackendFactory",
58 "iOS backend requested on non-iOS platform");
59 return nullptr;
60#endif
61
63 return std::make_unique<NullWindowBackend>();
64
66 default:
67 return Create(GetDefaultType());
68 }
69}
70
72#if defined(__APPLE__) && \
73 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
75#endif
76#ifdef YAZE_USE_SDL3
78#else
80#endif
81}
82
84 switch (type) {
86#ifdef YAZE_USE_SDL3
87 return false; // Built with SDL3, SDL2 not available
88#else
89 return true;
90#endif
91
93#ifdef YAZE_USE_SDL3
94 return true;
95#else
96 return false; // SDL3 not built in
97#endif
98
100 return false; // Declared but not runtime-implemented yet
101
103 return true; // Auto always available
104
106#if defined(__APPLE__) && \
107 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
108 return true;
109#else
110 return false;
111#endif
112
114 return true;
115
116 default:
117 return false;
118 }
119}
120
121} // namespace platform
122} // 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:284