48 struct GHOST_BackendInfo {
49 const char *
id =
nullptr;
51 std::string failure_msg;
53 std::vector<GHOST_BackendInfo> backends_attempted;
57#if defined(WITH_HEADLESS)
59#elif defined(WITH_GHOST_WAYLAND)
60# if defined(WITH_GHOST_WAYLAND_DYNLOAD)
61 const bool has_wayland_libraries = ghost_wl_dynload_libraries_init();
63 const bool has_wayland_libraries =
true;
67#if defined(WITH_HEADLESS)
69#elif defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
71 if (has_wayland_libraries) {
72 backends_attempted.push_back({
"WAYLAND"});
77 catch (
const std::runtime_error &e) {
79 backends_attempted.back().failure_msg = e.what();
81 CLOG_INFO(&
LOG,
"Wayland system not created, falling back to X11");
84# ifdef WITH_GHOST_WAYLAND_DYNLOAD
85 ghost_wl_dynload_libraries_exit();
95 backends_attempted.push_back({
"X11"});
100 catch (
const std::runtime_error &e) {
102 backends_attempted.back().failure_msg = e.what();
108#elif defined(WITH_GHOST_X11)
109 backends_attempted.push_back({
"X11"});
114 catch (
const std::runtime_error &e) {
116 backends_attempted.back().failure_msg = e.what();
121#elif defined(WITH_GHOST_WAYLAND)
122 if (has_wayland_libraries) {
123 backends_attempted.push_back({
"WAYLAND"});
128 catch (
const std::runtime_error &e) {
130 backends_attempted.back().failure_msg = e.what();
134# ifdef WITH_GHOST_WAYLAND_DYNLOAD
135 ghost_wl_dynload_libraries_exit();
142#elif defined(WITH_GHOST_SDL)
143 backends_attempted.push_back({
"SDL"});
148 catch (
const std::runtime_error &e) {
150 backends_attempted.back().failure_msg = e.what();
156 backends_attempted.push_back({
"WIN32"});
159#elif defined(__APPLE__)
160 backends_attempted.push_back({
"COCOA"});
169 bool show_messages =
false;
170 std::string msg =
"Failed to initialize display for back-end(s): [";
171 for (
int i = 0; i < backends_attempted.size(); i++) {
172 const GHOST_BackendInfo &backend_item = backends_attempted[i];
176 msg +=
"'" + std::string(backend_item.id) +
"'";
177 if (!backend_item.failure_msg.empty()) {
178 show_messages =
true;
183 for (
int i = 0; i < backends_attempted.size(); i++) {
184 const GHOST_BackendInfo &backend_item = backends_attempted[i];
186 msg += backend_item.id;
188 msg += backend_item.failure_msg.empty() ?
"<unknown>" : backend_item.failure_msg.c_str();
194#ifdef WITH_GHOST_WAYLAND
195# ifndef WITH_GHOST_X11
200 const char *wayland_display = getenv(
"WAYLAND_DISPLAY");
201 if (!(wayland_display && wayland_display[0])) {
202 const char *x11_display = getenv(
"DISPLAY");
203 if (x11_display && x11_display[0]) {
210 "Built without X11 support, enable \"WITH_GHOST_X11\" build-option to use X11.\n");