49 struct GHOST_BackendInfo {
50 const char *
id =
nullptr;
52 std::string failure_msg;
54 std::vector<GHOST_BackendInfo> backends_attempted;
58#if defined(WITH_HEADLESS)
60#elif defined(WITH_GHOST_WAYLAND)
61# if defined(WITH_GHOST_WAYLAND_DYNLOAD)
64 const bool has_wayland_libraries = ghost_wl_dynload_libraries_init(
67 const bool has_wayland_libraries =
true;
71#if defined(WITH_HEADLESS)
73#elif defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
75 if (has_wayland_libraries) {
76 backends_attempted.push_back({
"WAYLAND"});
81 catch (
const std::runtime_error &
e) {
83 backends_attempted.back().failure_msg =
e.what();
85 CLOG_INFO(&
LOG,
"Wayland system not created, falling back to X11");
88# ifdef WITH_GHOST_WAYLAND_DYNLOAD
89 ghost_wl_dynload_libraries_exit();
99 backends_attempted.push_back({
"X11"});
104 catch (
const std::runtime_error &
e) {
106 backends_attempted.back().failure_msg =
e.what();
112#elif defined(WITH_GHOST_X11)
113 backends_attempted.push_back({
"X11"});
118 catch (
const std::runtime_error &
e) {
120 backends_attempted.back().failure_msg =
e.what();
125#elif defined(WITH_GHOST_WAYLAND)
126 if (has_wayland_libraries) {
127 backends_attempted.push_back({
"WAYLAND"});
132 catch (
const std::runtime_error &
e) {
134 backends_attempted.back().failure_msg =
e.what();
138# ifdef WITH_GHOST_WAYLAND_DYNLOAD
139 ghost_wl_dynload_libraries_exit();
146#elif defined(WITH_GHOST_SDL)
147 backends_attempted.push_back({
"SDL"});
152 catch (
const std::runtime_error &
e) {
154 backends_attempted.back().failure_msg =
e.what();
160 backends_attempted.push_back({
"WIN32"});
163#elif defined(__APPLE__)
164 backends_attempted.push_back({
"COCOA"});
173 bool show_messages =
false;
174 std::string msg =
"Failed to initialize display for back-end(s): [";
175 for (
int i = 0;
i < backends_attempted.size();
i++) {
176 const GHOST_BackendInfo &backend_item = backends_attempted[
i];
180 msg +=
"'" + std::string(backend_item.id) +
"'";
181 if (!backend_item.failure_msg.empty()) {
182 show_messages =
true;
187 for (
int i = 0;
i < backends_attempted.size();
i++) {
188 const GHOST_BackendInfo &backend_item = backends_attempted[
i];
190 msg += backend_item.id;
192 msg += backend_item.failure_msg.empty() ?
"<unknown>" : backend_item.failure_msg.c_str();