write a class with 

#define EGL_DEFAULT_WINDOW EGL_CAST(EGLNativeWindowType, 0)
/* esCreateWindow flag - RGB color buffer */
#define ES_WINDOW_RGB 0
/* esCreateWindow flag - ALPHA color buffer */
#define ES_WINDOW_ALPHA 1
/* esCreateWindow flag - depth buffer */
#define ES_WINDOW_DEPTH 2
/* esCreateWindow flag - stencil buffer */
#define ES_WINDOW_STENCIL 4
/* esCreateWindow flat - multi-sample buffer */
#define ES_WINDOW_MULTISAMPLE 8



EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};

EGLint attribList[] =
    {
        EGL_RED_SIZE, 5,
        EGL_GREEN_SIZE, 6,
        EGL_BLUE_SIZE, 5,
        EGL_ALPHA_SIZE, (ES_WINDOW_RGB & ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE,
        EGL_DEPTH_SIZE, (ES_WINDOW_RGB & ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE,
        EGL_STENCIL_SIZE, (ES_WINDOW_RGB & ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE,
        EGL_SAMPLE_BUFFERS, (ES_WINDOW_RGB & ES_WINDOW_MULTISAMPLE) ? 1 : 0,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_NONE};

struct wl_compositor *compositor;
struct wl_subcompositor *subcompositor;
struct wl_shm *shm;
struct wl_shell *shell;
struct wl_surface *parent_surface;
struct wl_surface *child_surface;
struct wl_display *display;

EGLNativeDisplayType eglNativeDisplayType = NULL;
EGLDisplay egldisplay = NULL;

EGLNativeWindowType native_window = NULL;
EGLSurface eglsurface = NULL;

EGLContext eglcontext = NULL;

EGLint majorVersion;
EGLint minorVersion;
EGLBoolean eRetStatus;

EGLConfig config;
EGLint numConfigs;

void registry_global_remove_handler(
    void *data,
    struct wl_registry *registry,
    uint32_t name) {}

void registry_global_handler(
    void *data,
    struct wl_registry *registry,
    uint32_t name,
    const char *interface,
    uint32_t version)
{
    if (strcmp(interface, "wl_compositor") == 0)
    {
        compositor = (wl_compositor *)wl_registry_bind(registry, name,
                                                       &wl_compositor_interface, 3);
    }
    else if (strcmp(interface, "wl_subcompositor") == 0)
    {
        subcompositor = (wl_subcompositor *)wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
    }
    else if (strcmp(interface, "wl_shm") == 0)
    {
        shm = (wl_shm *)wl_registry_bind(registry, name,
                                         &wl_shm_interface, 1);
    }
    else if (strcmp(interface, "wl_shell") == 0)
    {
        shell = (wl_shell *)wl_registry_bind(registry, name,
                                             &wl_shell_interface, 1);
    }
}

bool displayInit_Wayland(void)
{
    int width = 1;
    int height = 1;
    int stride = width * 4;
    int size = stride * height;

    const struct wl_registry_listener registry_listener = {
        .global = registry_global_handler,
        .global_remove = registry_global_remove_handler};

    struct wl_subsurface *subsurface;
    display = wl_display_connect(NULL);
    struct wl_registry *registry = wl_display_get_registry(display);
    wl_registry_add_listener(registry, &registry_listener, NULL);

    // wait for the "initial" set of globals to appear
    wl_display_roundtrip(display);

    child_surface = wl_compositor_create_surface(compositor);
    parent_surface = wl_compositor_create_surface(compositor);
    subsurface = wl_subcompositor_get_subsurface(subcompositor, child_surface, parent_surface);
    struct wl_shell_surface *shell_surface = wl_shell_get_shell_surface(shell, parent_surface);
    wl_shell_surface_set_toplevel(shell_surface);

    int fd = syscall(SYS_memfd_create, "buffer", 0);
    ftruncate(fd, size);
    unsigned char *data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    struct wl_shm_pool *pool = wl_shm_create_pool(shm, fd, size);
    struct wl_buffer *buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, WL_SHM_FORMAT_XRGB8888);
    wl_surface_attach(parent_surface, buffer, 0, 0);
    wl_subsurface_set_desync(subsurface);
    wl_subsurface_set_position(subsurface, 0, 200);

    egldisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
    if (egldisplay == EGL_NO_DISPLAY)
    {
        cout << "Error while eglGetDisplay" << endl;
    }

    eRetStatus = eglInitialize(egldisplay, &majorVersion, &minorVersion);
    if (eRetStatus != EGL_TRUE)
    {
        cout << "Error while eglInitialize" << endl;
    }

    eRetStatus = eglChooseConfig(egldisplay, attribList, &config, 1, &numConfigs);
    if (eRetStatus != EGL_TRUE)
    {
        cout << "Error while eglChooseConfig" << endl;
    }

    // native_window = EGL_DEFAULT_WINDOW;
    native_window = wl_egl_window_create(child_surface, CLUSTER_WIDTH, CLUSTER_HEIGHT);
    eglsurface = eglCreateWindowSurface(egldisplay, config,
                                        native_window, NULL);
    if (eglsurface == EGL_NO_SURFACE)
    {
        cout << "Error while eglCreateWindowSurface" << endl;
    }

    eglcontext = eglCreateContext(egldisplay, config,
                                  EGL_NO_CONTEXT, contextAttribs);

    if (eglcontext == EGL_NO_CONTEXT)
    {
        cout << "Error while eglCreateContext" << endl;
    }

    eRetStatus = eglMakeCurrent(egldisplay, eglsurface,
                                eglsurface, eglcontext);

    if (eRetStatus == EGL_TRUE)
    {
        return true;
    }
    else
    {
        return false;
    }
}