Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmake/dependencies/glad.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ glad_add_library(glad_egl
EXTENSIONS
EGL_EXT_image_dma_buf_import
EGL_EXT_image_dma_buf_import_modifiers
EGL_EXT_platform_base
EGL_EXT_platform_wayland
EGL_EXT_platform_x11
EGL_KHR_create_context
EGL_KHR_image_base
EGL_KHR_surfaceless_context
EGL_MESA_platform_gbm
)

# GL compatibility=4.6 --loader --mx
Expand Down
23 changes: 16 additions & 7 deletions src/platform/linux/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ namespace egl {
* @memberof egl::display_t
*/
display_t make_display(std::variant<gbm::gbm_t::pointer, wl_display *, _XDisplay *> native_display) {
constexpr auto EGL_PLATFORM_GBM_MESA = 0x31D7;
constexpr auto EGL_PLATFORM_WAYLAND_KHR = 0x31D8;
constexpr auto EGL_PLATFORM_X11_KHR = 0x31D5;

int egl_platform;
void *native_display_p;

Expand All @@ -338,12 +334,20 @@ namespace egl {
}

// native_display.left() equals native_display.right()
display_t display = eglGetPlatformDisplay(egl_platform, native_display_p, nullptr);
EGLDisplay raw_display = EGL_NO_DISPLAY;

if (fail()) {
BOOST_LOG(error) << "Couldn't open EGL display: ["sv << util::hex(eglGetError()).to_string_view() << ']';
if (eglGetPlatformDisplayEXT) {
raw_display = eglGetPlatformDisplayEXT(egl_platform, native_display_p, nullptr);
} else if (eglGetPlatformDisplay) {
raw_display = eglGetPlatformDisplay(egl_platform, native_display_p, nullptr);
}

if (raw_display == EGL_NO_DISPLAY) {
BOOST_LOG(error) << "Couldn't open EGL display: ["sv
<< util::hex(eglGetError()).to_string_view() << ']';
return nullptr;
}
display_t display {raw_display};

int major;
int minor;
Expand All @@ -352,6 +356,11 @@ namespace egl {
return nullptr;
}

if (!gladLoaderLoadEGL(display.get())) {
BOOST_LOG(error) << "Failed to reload EGL for initialized display"sv;
return nullptr;
}

const char *extension_st = eglQueryString(display.get(), EGL_EXTENSIONS);
const char *version = eglQueryString(display.get(), EGL_VERSION);
const char *vendor = eglQueryString(display.get(), EGL_VENDOR);
Expand Down
5 changes: 3 additions & 2 deletions src/platform/linux/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,9 @@ namespace platf {
return nullptr;
}

if (!gladLoaderLoadEGL(EGL_NO_DISPLAY) || !eglGetPlatformDisplay) {
BOOST_LOG(warning) << "Couldn't load EGL library"sv;
if (!gladLoaderLoadEGL(NULL)) {
BOOST_LOG(error) << "Failed to load EGL library symbols"sv;
return nullptr;
}

return std::make_unique<deinit_t>();
Expand Down
Loading