44 struct GHOST_BackendInfo {
45 const char *
id =
nullptr;
47 std::string failure_msg;
49 std::vector<GHOST_BackendInfo> backends_attempted;
54#if defined(WITH_HEADLESS)
56#elif defined(WITH_GHOST_WAYLAND)
57# if defined(WITH_GHOST_WAYLAND_DYNLOAD)
58 const bool has_wayland_libraries = ghost_wl_dynload_libraries_init();
60 const bool has_wayland_libraries =
true;
64#if defined(WITH_HEADLESS)
66#elif defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
68 if (has_wayland_libraries) {
69 backends_attempted.push_back({
"WAYLAND"});
73 catch (
const std::runtime_error &
e) {
75 backends_attempted.back().failure_msg =
e.what();
79# ifdef WITH_GHOST_WAYLAND_DYNLOAD
80 ghost_wl_dynload_libraries_exit();
90 backends_attempted.push_back({
"X11"});
94 catch (
const std::runtime_error &
e) {
96 backends_attempted.back().failure_msg =
e.what();
102#elif defined(WITH_GHOST_X11)
103 backends_attempted.push_back({
"X11"});
107 catch (
const std::runtime_error &
e) {
109 backends_attempted.back().failure_msg =
e.what();
114#elif defined(WITH_GHOST_WAYLAND)
115 if (has_wayland_libraries) {
116 backends_attempted.push_back({
"WAYLAND"});
120 catch (
const std::runtime_error &
e) {
122 backends_attempted.back().failure_msg =
e.what();
126# ifdef WITH_GHOST_WAYLAND_DYNLOAD
127 ghost_wl_dynload_libraries_exit();
134#elif defined(WITH_GHOST_SDL)
135 backends_attempted.push_back({
"SDL"});
139 catch (
const std::runtime_error &
e) {
141 backends_attempted.back().failure_msg =
e.what();
147 backends_attempted.push_back({
"WIN32"});
149#elif defined(__APPLE__)
150 backends_attempted.push_back({
"COCOA"});
158 bool show_messages =
false;
159 fprintf(stderr,
"GHOST: failed to initialize display for back-end(s): [");
160 for (
int i = 0; i < backends_attempted.size(); i++) {
161 const GHOST_BackendInfo &backend_item = backends_attempted[i];
163 fprintf(stderr,
", ");
165 fprintf(stderr,
"'%s'", backend_item.id);
166 if (!backend_item.failure_msg.empty()) {
167 show_messages =
true;
170 fprintf(stderr,
"]\n");
172 for (
int i = 0; i < backends_attempted.size(); i++) {
173 const GHOST_BackendInfo &backend_item = backends_attempted[i];
177 backend_item.failure_msg.empty() ?
"<unknown>" :
178 backend_item.failure_msg.c_str());