xcb_create_colormap, how to use?

Thomas Fischer <[email protected]>
Newsgroups gmane.comp.freedesktop.xcb
Message-ID <CAGbX=_UcAegYq5Kd=DTHfHLTbH1D=wUzHzYip=3F_8OuAjngwg@mail.gmail.com>
I've been trying to compile the code from
https://xcb.freedesktop.org/opengl/
tl;dr: The code used Xlib to interact with glx, but uses xcb to handle X
events.

It seems to not run because of something happening in xcb_create_colormap,

I changed the code to use create_colormap_checked, and printed out the
error structure, this was the response, if it's useful:
=============ERROR=============
Could not create the colormap
        error->response_type: 0
        error->error_code: 8
        error->sequence: 31
        error->resource_id: 0
        error->minor_code: 0
        error->major_code: 78
        error->full_sequence: 31
===============================

Curious if using xlib was messing something up, I made a version using only
xcb, which works, meaning it creates a window:

xcb_window_t window = xcb_generate_id(connection);
window = xcb_generate_id(connection);
xcb_colormap_t colormap = xcb_generate_id(connection);

//Try to create a colormap
xcb_void_cookie_t cookie_colormap =
xcb_create_colormap_checked(connection,
                            XCB_COLORMAP_ALLOC_NONE,
                            colormap,
                            screen->root, screen->root_visual);

xcb_generic_error_t *error = xcb_request_check(connection,
                             cookie_colormap);
if (error)
{
    fprintf(stderr, "Could not create colormap!\n");
    xcb_disconnect(connection);
    return 1;
}

uint32_t mask;
uint32_t values[3];
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
values[0] = screen->white_pixel;
values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS;
values[2] = colormap;

xcb_create_window(connection,
                  XCB_COPY_FROM_PARENT,
                  window,
                  screen->root,
                  0, 0,
                  150, 150,
                  10,
                  XCB_WINDOW_CLASS_INPUT_OUTPUT,
                  screen->root_visual,
                  mask, values);

xcb_map_window(connection, window);
xcb_flush(connection);

I'm still confused why the opengl example doesn't work. I'd like to use xcb,
since I think it's a much nicer api than Xlib.

Could anyone kindly help me understand how to use this function?

_______________________________________________
Xcb mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xcb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.