Esempio n. 1
0
struct wcore_platform*
glx_platform_create(void)
{
    struct glx_platform *self;
    bool ok = true;

    self = wcore_calloc(sizeof(*self));
    if (self == NULL)
        return NULL;

    ok = wcore_platform_init(&self->wcore);
    if (!ok)
        goto error;

    self->linux = linux_platform_create();
    if (!self->linux)
        goto error;

    self->glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const uint8_t*) "glXCreateContextAttribsARB");

    self->wcore.vtbl = &glx_platform_vtbl;
    return &self->wcore;

error:
    glx_platform_destroy(&self->wcore);
    return NULL;
}
Esempio n. 2
0
struct wcore_platform*
wgbm_platform_create(void)
{
    struct wgbm_platform *self;
    bool ok = true;

    self = wcore_calloc(sizeof(*self));
    if (self == NULL)
        return NULL;

    ok = wcore_platform_init(&self->wcore);
    if (!ok)
        goto error;

    self->linux = linux_platform_create();
    if (!self->linux)
        goto error;

    setenv("EGL_PLATFORM", "drm", true);

    self->wcore.vtbl = &wgbm_platform_vtbl;
    return &self->wcore;

error:
    wgbm_platform_destroy(&self->wcore);
    return NULL;
}
Esempio n. 3
0
struct wcore_platform*
glx_platform_create(void)
{
    struct glx_platform *self;
    bool ok = true;

    self = wcore_calloc(sizeof(*self));
    if (self == NULL)
        return NULL;

    ok = wcore_platform_init(&self->wcore);
    if (!ok)
        goto error;

    self->glxHandle = dlopen(libGL_filename, RTLD_LAZY | RTLD_LOCAL);
    if (!self->glxHandle) {
        wcore_errorf(WAFFLE_ERROR_FATAL,
                     "dlopen(\"%s\") failed: %s",
                     libGL_filename, dlerror());
        goto error;
    }

#define RETRIEVE_GLX_SYMBOL(function)                                  \
    self->function = dlsym(self->glxHandle, #function);                \
    if (!self->function) {                                             \
        wcore_errorf(WAFFLE_ERROR_FATAL,                             \
                     "dlsym(\"%s\", \"" #function "\") failed: %s",    \
                     libGL_filename, dlerror());                      \
        goto error;                                                    \
    }

    RETRIEVE_GLX_SYMBOL(glXCreateNewContext);
    RETRIEVE_GLX_SYMBOL(glXDestroyContext);
    RETRIEVE_GLX_SYMBOL(glXMakeCurrent);

    RETRIEVE_GLX_SYMBOL(glXQueryExtensionsString);
    RETRIEVE_GLX_SYMBOL(glXGetProcAddress);

    RETRIEVE_GLX_SYMBOL(glXGetVisualFromFBConfig);
    RETRIEVE_GLX_SYMBOL(glXGetFBConfigAttrib);
    RETRIEVE_GLX_SYMBOL(glXChooseFBConfig);

    RETRIEVE_GLX_SYMBOL(glXSwapBuffers);
#undef RETRIEVE_GLX_SYMBOL

    self->linux = linux_platform_create();
    if (!self->linux)
        goto error;

    self->glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) self->glXGetProcAddress((const uint8_t*) "glXCreateContextAttribsARB");

    self->wcore.vtbl = &glx_platform_vtbl;
    return &self->wcore;

error:
    glx_platform_destroy(&self->wcore);
    return NULL;
}
Esempio n. 4
0
struct wcore_platform*
wayland_platform_create(void)
{
    struct wayland_platform *self;
    bool ok = true;

    self = wcore_calloc(sizeof(*self));
    if (self == NULL)
        return NULL;

    ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_WAYLAND_KHR);
    if (!ok)
        goto error;

    ok = wayland_wrapper_init();
    if (!ok)
        goto error;

    self->dl_wl_egl = dlopen(libwl_egl_filename, RTLD_LAZY | RTLD_LOCAL);
    if (!self->dl_wl_egl) {
        wcore_errorf(WAFFLE_ERROR_FATAL,
                     "dlopen(\"%s\") failed: %s",
                     libwl_egl_filename, dlerror());
        goto error;
    }

#define RETRIEVE_WL_EGL_SYMBOL(function)                                  \
    self->function = dlsym(self->dl_wl_egl, #function);                \
    if (!self->function) {                                             \
        wcore_errorf(WAFFLE_ERROR_FATAL,                             \
                     "dlsym(\"%s\", \"" #function "\") failed: %s",    \
                     libwl_egl_filename, dlerror());                      \
        goto error;                                                    \
    }

    RETRIEVE_WL_EGL_SYMBOL(wl_egl_window_create);
    RETRIEVE_WL_EGL_SYMBOL(wl_egl_window_destroy);
    RETRIEVE_WL_EGL_SYMBOL(wl_egl_window_resize);

#undef RETRIEVE_WL_EGL_SYMBOL

    self->linux = linux_platform_create();
    if (!self->linux)
        goto error;

    self->wegl.wcore.vtbl = &wayland_platform_vtbl;
    return &self->wegl.wcore;

error:
    wayland_platform_destroy(&self->wegl.wcore);
    return NULL;
}