Exemplo n.º 1
0
static bool
test_glx_extension_supported(void)
{
    if (!epoxy_has_glx_extension(dpy, 0, "GLX_ARB_get_proc_address")) {
        fputs("Incorrectly reported no support for GLX_ARB_get_proc_address "
              "(should always be present in Linux ABI)\n",
              stderr);
        return false;
    }

    if (epoxy_has_glx_extension(dpy, 0, "GLX_EXT_ham_sandwich")) {
        fputs("Incorrectly reported support for GLX_EXT_ham_sandwich\n",
              stderr);
        return false;
    }

    return true;
}
Exemplo n.º 2
0
struct ephyr_glamor *
ephyr_glamor_glx_screen_init(xcb_window_t win)
{
    GLXContext ctx;
    struct ephyr_glamor *glamor;
    GLXWindow glx_win;

    glamor = calloc(1, sizeof(struct ephyr_glamor));
    if (!glamor) {
        FatalError("malloc");
        return NULL;
    }

    glx_win = glXCreateWindow(dpy, fb_config, win, NULL);

    if (ephyr_glamor_gles2) {
        static const int context_attribs[] = {
            GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
            GLX_CONTEXT_MINOR_VERSION_ARB, 0,
            GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES_PROFILE_BIT_EXT,
            0,
        };
        if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
                                    "GLX_EXT_create_context_es2_profile")) {
            ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
                                             context_attribs);
        } else {
            FatalError("Xephyr -glamor_gles2 rquires "
                       "GLX_EXT_create_context_es2_profile\n");
        }
    } else {
        ctx = glXCreateContext(dpy, visual_info, NULL, True);
    }
    if (ctx == NULL)
        FatalError("glXCreateContext failed\n");

    if (!glXMakeCurrent(dpy, glx_win, ctx))
        FatalError("glXMakeCurrent failed\n");

    glamor->ctx = ctx;
    glamor->win = win;
    glamor->glx_win = glx_win;
    ephyr_glamor_setup_texturing_shader(glamor);

    return glamor;
}
Exemplo n.º 3
0
struct ephyr_glamor *
ephyr_glamor_glx_screen_init(xcb_window_t win)
{
    int (*oldErrorHandler) (Display *, XErrorEvent *);
    static const float position[] = {
        -1, -1,
         1, -1,
         1,  1,
        -1,  1,
        0, 1,
        1, 1,
        1, 0,
        0, 0,
    };
    GLint old_vao;

    GLXContext ctx;
    struct ephyr_glamor *glamor;
    GLXWindow glx_win;

    glamor = calloc(1, sizeof(struct ephyr_glamor));
    if (!glamor) {
        FatalError("malloc");
        return NULL;
    }

    glx_win = glXCreateWindow(dpy, fb_config, win, NULL);

    if (ephyr_glamor_gles2) {
        static const int context_attribs[] = {
            GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
            GLX_CONTEXT_MINOR_VERSION_ARB, 0,
            GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES_PROFILE_BIT_EXT,
            0,
        };
        if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
                                    "GLX_EXT_create_context_es2_profile")) {
            ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
                                             context_attribs);
        } else {
            FatalError("Xephyr -glamor_gles2 rquires "
                       "GLX_EXT_create_context_es2_profile\n");
        }
    } else {
        if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
                                    "GLX_ARB_create_context")) {
            static const int context_attribs[] = {
                GLX_CONTEXT_PROFILE_MASK_ARB,
                GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
                GLX_CONTEXT_MAJOR_VERSION_ARB,
                GLAMOR_GL_CORE_VER_MAJOR,
                GLX_CONTEXT_MINOR_VERSION_ARB,
                GLAMOR_GL_CORE_VER_MINOR,
                0,
            };
            oldErrorHandler = XSetErrorHandler(ephyr_glx_error_handler);
            ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
                                             context_attribs);
            XSync(dpy, False);
            XSetErrorHandler(oldErrorHandler);
        } else {
            ctx = NULL;
        }

        if (!ctx)
            ctx = glXCreateContext(dpy, visual_info, NULL, True);
    }
    if (ctx == NULL)
        FatalError("glXCreateContext failed\n");

    if (!glXMakeCurrent(dpy, glx_win, ctx))
        FatalError("glXMakeCurrent failed\n");

    glamor->ctx = ctx;
    glamor->win = win;
    glamor->glx_win = glx_win;
    ephyr_glamor_setup_texturing_shader(glamor);

    if (epoxy_has_gl_extension("GL_ARB_vertex_array_object")) {
        glGenVertexArrays(1, &glamor->vao);
        glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &old_vao);
        glBindVertexArray(glamor->vao);
    } else
        glamor->vao = 0;

    glGenBuffers(1, &glamor->vbo);

    glBindBuffer(GL_ARRAY_BUFFER, glamor->vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof (position), position, GL_STATIC_DRAW);

    if (glamor->vao) {
        ephyr_glamor_set_vertices(glamor);
        glBindVertexArray(old_vao);
    } else
        glBindBuffer(GL_ARRAY_BUFFER, 0);

    return glamor;
}