Example #1
0
/// On Linux, according to eglplatform.h, EGLNativeDisplayType and intptr_t
/// have the same size regardless of platform.
bool
wegl_display_init(struct wegl_display *dpy,
                  struct wcore_platform *wc_plat,
                  intptr_t native_display)
{
    bool ok;
    EGLint major, minor;

    ok = wcore_display_init(&dpy->wcore, wc_plat);
    if (!ok)
        goto fail;

    dpy->egl = eglGetDisplay((EGLNativeDisplayType) native_display);
    if (!dpy->egl) {
        wegl_emit_error("eglGetDisplay");
        goto fail;
    }

    ok = eglInitialize(dpy->egl, &major, &minor);
    if (!ok) {
        wegl_emit_error("eglInitialize");
        goto fail;
    }

    ok = get_extensions(dpy);
    if (!ok)
	goto fail;

    return true;

fail:
    wegl_display_teardown(dpy);
    return false;
}
Example #2
0
bool
wegl_display_teardown(struct wegl_display *dpy)
{
    bool ok = true;

    if (dpy->egl) {
        ok = eglTerminate(dpy->egl);
        if (!ok)
            wegl_emit_error("eglTerminate");
    }

    return ok;
}
Example #3
0
struct wcore_window*
xegl_window_create(struct wcore_platform *wc_plat,
                   struct wcore_config *wc_config,
                   int width,
                   int height)
{
    struct xegl_window *self;
    struct xegl_display *dpy = xegl_display(wc_config->display);
    struct wegl_config *config = wegl_config(wc_config);
    xcb_visualid_t visual;
    bool ok = true;

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

    ok = eglGetConfigAttrib(dpy->wegl.egl,
                            config->egl,
                            EGL_NATIVE_VISUAL_ID,
                            (EGLint*) &visual);
    if (!ok) {
        wegl_emit_error("eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID)");
        goto error;
    }

    ok = x11_window_init(&self->x11,
                         &dpy->x11,
                         visual,
                         width,
                         height);
    if (!ok)
        goto error;

    ok = wegl_window_init(&self->wegl,
                          &config->wcore,
                          (intptr_t) self->x11.xcb);
    if (!ok)
        goto error;

    return &self->wegl.wcore;

error:
    xegl_window_destroy(&self->wegl.wcore);
    return NULL;
}
Example #4
0
static bool
get_extensions(struct wegl_display *dpy)
{
    const char *extensions = eglQueryString(dpy->egl, EGL_EXTENSIONS);

    if (!extensions) {
	wegl_emit_error("eglQueryString(EGL_EXTENSIONS");
	return false;
    }

    // waffle_is_extension_in_string() resets the error state. That's ok,
    // however, because if we've reached this point then no error should be
    // pending emission.
    assert(wcore_error_get_code() == 0);

    dpy->KHR_create_context = waffle_is_extension_in_string(extensions, "EGL_KHR_create_context");

    return true;
}
Example #5
0
bool
wegl_make_current(struct wcore_platform *wc_plat,
                  struct wcore_display *wc_dpy,
                  struct wcore_window *wc_window,
                  struct wcore_context *wc_ctx)
{
    struct wegl_platform *plat = wegl_platform(wc_plat);
    EGLSurface surface = wc_window ? wegl_window(wc_window)->egl : NULL;
    bool ok;

    ok = plat->eglMakeCurrent(wegl_display(wc_dpy)->egl,
                              surface,
                              surface,
                              wc_ctx
                                  ? wegl_context(wc_ctx)->egl
                                  : NULL);
    if (!ok)
        wegl_emit_error(plat, "eglMakeCurrent");

    return ok;
}