43 struct GHOST_BackendInfo {
44 const char *
id =
nullptr;
46 std::string failure_msg;
48 std::vector<GHOST_BackendInfo> backends_attempted;
53#if defined(WITH_HEADLESS)
55#elif defined(WITH_GHOST_WAYLAND)
56# if defined(WITH_GHOST_WAYLAND_DYNLOAD)
57 const bool has_wayland_libraries = ghost_wl_dynload_libraries_init();
59 const bool has_wayland_libraries =
true;
63#if defined(WITH_HEADLESS)
65#elif defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
67 if (has_wayland_libraries) {
68 backends_attempted.push_back({
"WAYLAND"});
72 catch (
const std::runtime_error &
e) {
74 backends_attempted.back().failure_msg =
e.what();
78# ifdef WITH_GHOST_WAYLAND_DYNLOAD
79 ghost_wl_dynload_libraries_exit();
89 backends_attempted.push_back({
"X11"});
93 catch (
const std::runtime_error &
e) {
95 backends_attempted.back().failure_msg =
e.what();
101#elif defined(WITH_GHOST_X11)
102 backends_attempted.push_back({
"X11"});
106 catch (
const std::runtime_error &
e) {
108 backends_attempted.back().failure_msg =
e.what();
113#elif defined(WITH_GHOST_WAYLAND)
114 if (has_wayland_libraries) {
115 backends_attempted.push_back({
"WAYLAND"});
119 catch (
const std::runtime_error &
e) {
121 backends_attempted.back().failure_msg =
e.what();
125# ifdef WITH_GHOST_WAYLAND_DYNLOAD
126 ghost_wl_dynload_libraries_exit();
133#elif defined(WITH_GHOST_SDL)
134 backends_attempted.push_back({
"SDL"});
138 catch (
const std::runtime_error &
e) {
140 backends_attempted.back().failure_msg =
e.what();
146 backends_attempted.push_back({
"WIN32"});
148#elif defined(__APPLE__)
149 backends_attempted.push_back({
"COCOA"});
157 bool show_messages =
false;
158 fprintf(stderr,
"GHOST: failed to initialize display for back-end(s): [");
159 for (
int i = 0;
i < backends_attempted.size();
i++) {
160 const GHOST_BackendInfo &backend_item = backends_attempted[
i];
162 fprintf(stderr,
", ");
164 fprintf(stderr,
"'%s'", backend_item.id);
165 if (!backend_item.failure_msg.empty()) {
166 show_messages =
true;
169 fprintf(stderr,
"]\n");
171 for (
int i = 0;
i < backends_attempted.size();
i++) {
172 const GHOST_BackendInfo &backend_item = backends_attempted[
i];
176 backend_item.failure_msg.empty() ?
"<unknown>" :
177 backend_item.failure_msg.c_str());