examples: drop wlroots dep from egl_common.c

Just use fprintf instead of wlr_log.
This commit is contained in:
Simon Ser 2021-02-08 13:45:52 +01:00
parent 5e19e0053a
commit 12cc465144

View file

@ -5,7 +5,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wlr/util/log.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
@ -39,37 +38,34 @@ bool egl_init(struct wl_display *display) {
eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (client_exts_str == NULL) { if (client_exts_str == NULL) {
if (eglGetError() == EGL_BAD_DISPLAY) { if (eglGetError() == EGL_BAD_DISPLAY) {
wlr_log(WLR_ERROR, fprintf(stderr, "EGL_EXT_client_extensions not supported\n");
"EGL_EXT_client_extensions not supported");
} else { } else {
wlr_log(WLR_ERROR, fprintf(stderr, "Failed to query EGL client extensions\n");
"Failed to query EGL client extensions");
} }
return false; return false;
} }
if (!strstr(client_exts_str, "EGL_EXT_platform_base")) { if (!strstr(client_exts_str, "EGL_EXT_platform_base")) {
wlr_log(WLR_ERROR, "EGL_EXT_platform_base not supported"); fprintf(stderr, "EGL_EXT_platform_base not supported\n");
return false; return false;
} }
if (!strstr(client_exts_str, "EGL_EXT_platform_wayland")) { if (!strstr(client_exts_str, "EGL_EXT_platform_wayland")) {
wlr_log(WLR_ERROR, "EGL_EXT_platform_wayland not supported"); fprintf(stderr, "EGL_EXT_platform_wayland not supported\n");
return false; return false;
} }
eglGetPlatformDisplayEXT = eglGetPlatformDisplayEXT =
(void *)eglGetProcAddress("eglGetPlatformDisplayEXT"); (void *)eglGetProcAddress("eglGetPlatformDisplayEXT");
if (eglGetPlatformDisplayEXT == NULL) { if (eglGetPlatformDisplayEXT == NULL) {
wlr_log(WLR_ERROR, "Failed to get eglGetPlatformDisplayEXT"); fprintf(stderr, "Failed to get eglGetPlatformDisplayEXT\n");
return false; return false;
} }
eglCreatePlatformWindowSurfaceEXT = eglCreatePlatformWindowSurfaceEXT =
(void *)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"); (void *)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
if (eglCreatePlatformWindowSurfaceEXT == NULL) { if (eglCreatePlatformWindowSurfaceEXT == NULL) {
wlr_log(WLR_ERROR, fprintf(stderr, "Failed to get eglCreatePlatformWindowSurfaceEXT\n");
"Failed to get eglCreatePlatformWindowSurfaceEXT");
return false; return false;
} }
@ -77,23 +73,23 @@ bool egl_init(struct wl_display *display) {
eglGetPlatformDisplayEXT(EGL_PLATFORM_WAYLAND_EXT, eglGetPlatformDisplayEXT(EGL_PLATFORM_WAYLAND_EXT,
display, NULL); display, NULL);
if (egl_display == EGL_NO_DISPLAY) { if (egl_display == EGL_NO_DISPLAY) {
wlr_log(WLR_ERROR, "Failed to create EGL display"); fprintf(stderr, "Failed to create EGL display\n");
goto error; goto error;
} }
if (eglInitialize(egl_display, NULL, NULL) == EGL_FALSE) { if (eglInitialize(egl_display, NULL, NULL) == EGL_FALSE) {
wlr_log(WLR_ERROR, "Failed to initialize EGL"); fprintf(stderr, "Failed to initialize EGL\n");
goto error; goto error;
} }
EGLint matched = 0; EGLint matched = 0;
if (!eglChooseConfig(egl_display, config_attribs, if (!eglChooseConfig(egl_display, config_attribs,
&egl_config, 1, &matched)) { &egl_config, 1, &matched)) {
wlr_log(WLR_ERROR, "eglChooseConfig failed"); fprintf(stderr, "eglChooseConfig failed\n");
goto error; goto error;
} }
if (matched == 0) { if (matched == 0) {
wlr_log(WLR_ERROR, "Failed to match an EGL config"); fprintf(stderr, "Failed to match an EGL config\n");
goto error; goto error;
} }
@ -101,7 +97,7 @@ bool egl_init(struct wl_display *display) {
eglCreateContext(egl_display, egl_config, eglCreateContext(egl_display, egl_config,
EGL_NO_CONTEXT, context_attribs); EGL_NO_CONTEXT, context_attribs);
if (egl_context == EGL_NO_CONTEXT) { if (egl_context == EGL_NO_CONTEXT) {
wlr_log(WLR_ERROR, "Failed to create EGL context"); fprintf(stderr, "Failed to create EGL context\n");
goto error; goto error;
} }