Пример #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;
}
Пример #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;
}
Пример #3
0
struct wcore_platform*
nacl_platform_create(void)
{
    struct nacl_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->nacl = nacl_container_init();
    if (!self->nacl)
        goto error;

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

error:
    nacl_platform_destroy(&self->wcore);
    return NULL;
}
Пример #4
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;
}