[Xcb] No opengl3 rendering

Remi Thebault remi.thebault at gmail.com
Mon Nov 2 11:15:06 PST 2015


Hello

I have the following findings:
 From a fully working Xlib client, switching only the event loop to xcb 
(keeping XCreateWindow and other xlib calls) makes it bug.
I.e. the first frame is rendered correctly, but all following ones have 
the background specified at window creation instead of the one set by 
glClearColor

the diff from the working to non-working version is as follow:

@@ -61,10 +61,11 @@ static int ctxErrorHandler( Display *dpy, 
XErrorEvent *ev )

  int main(int argc, char* argv[])
  {
      Display *display = XOpenDisplay(NULL);
+    xcb_connection_t *connection = XGetXCBConnection(display);
+    XSetEventQueueOwner(display, XCBOwnsEventQueue);

      if (!display)
      {
          printf("Failed to open X display\n");
          exit(1);
@@ -248,27 +249,28 @@ int main(int argc, char* argv[])
          printf( "Direct GLX rendering context obtained\n" );
      }

      double red=0;
      int exitLoop=0;
-    XEvent ev;

      while(!exitLoop) {

-        XNextEvent(display, &ev);
+        xcb_generic_event_t *e = xcb_wait_for_event(connection);

-        switch(ev.type) {
-        case Expose:
+        switch(e->response_type & ~0x80) {
+        case XCB_EXPOSE:
              glXMakeCurrent( display, win, ctx );
              glClearColor( red, 0.5, 1, 1 );
              glClear( GL_COLOR_BUFFER_BIT );
              glXSwapBuffers ( display, win );
              glXMakeCurrent( display, 0, 0 );
              red += 0.1;
              if (red > 1) red = 0;
              break;
-        case KeyPress:
+        case XCB_KEY_PRESS:
              exitLoop = 1;
              break;
          default:
              break;
          }

Any idea?

Remi


Le 01/11/2015 10:50, Remi Thebault a écrit :
> Hello
>
> I try to open a GL3 context in a window created with XCB but I can't 
> get it work.
> I can get a working context with Xlib / XGL API with the code here:
> www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_%28GLX%29
>
> When I replace the colormap and window creation with xcb code, I don't 
> get any error reported, but the window do not contain anything more 
> than the framebuffer content that was behind it.
>
> glXIsDirect and glXMakeCurrent both return 1, glGetError() do not 
> report anything
>
> any idea?
>
> here is a code extract:
>     XVisualInfo *vi = glXGetVisualFromFBConfig( display, bestFbc );
>
>     xcb_colormap_t cmap = xcb_generate_id(connection);
>     xcb_window_t xcb_win = xcb_generate_id(connection);
>
>
>     /* Create colormap */
>     xcb_create_colormap(
>         connection,
>         XCB_COLORMAP_ALLOC_NONE,
>         cmap,
>         screen->root,
>         vi->visualid
>         );
>
>     int cw_mask = XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK | 
> XCB_CW_COLORMAP;
>     int cw_values[] = {
>         0,                                  // border pixel
>         XCB_EVENT_MASK_STRUCTURE_NOTIFY,    // event mask
>         cmap                                // colormap
>     };
>
>     xcb_void_cookie_t cookie = xcb_create_window_checked(
>             connection,
>             vi->depth,
>             xcb_win,
>             screen->root,
>             0, 0,
>             640, 480,
>             0,
>             XCB_WINDOW_CLASS_INPUT_OUTPUT,
>             vi->visualid,
>             cw_mask,
>             cw_values
>         );
>
> Is it mandatory to create a GLXWindow on top of the xcb window?
> (I tried but without change in the result)
>
> thank you
> Remi



More information about the Xcb mailing list