You are not logged in.

#1 2012-11-26 13:58:31

AaronBP
Member
Registered: 2012-08-06
Posts: 149
Website

xcb or xlib (and EGL)

x.org suggests that we use xcb, but I notice that the documentation is all over the place and pretty poor. Also, it doesn't seem to be as widely used as they want it to be.

That said, xcb does advertise some compelling features, and Xlib doesn't exactly look perfect. So which should we be using?

Also, I notice that libegl depends on xcb. Can we cast an xcb connection to an EGL display?

Offline

#2 2012-11-26 20:50:47

AaronBP
Member
Registered: 2012-08-06
Posts: 149
Website

Re: xcb or xlib (and EGL)

There was some talk in the mailing list a couple years ago about supporting XCB in EGL, but I'm going to guess it never amounted to anything.

#include <stdlib.h>
#include <stdio.h>

#include <xcb/xcb.h>

#include <EGL/egl.h>

void fatal(char *);

int main(void)
{
	xcb_connection_t *xdisplay;
	EGLDisplay edisplay;
	xdisplay = xcb_connect(NULL,NULL);
	if(xcb_connection_has_error(xdisplay))
	{
		xcb_disconnect(xdisplay);
		fatal("Could not connect to X11 display.");
	}
	edisplay = eglGetDisplay((NativeDisplayType)xdisplay);
	if(edisplay == EGL_NO_DISPLAY)
	{
		eglTerminate(edisplay);
		xcb_disconnect(xdisplay);
		fatal("EGL failed to connect to display.");
	}
	if(!eglInitialize(edisplay, NULL, NULL))
	{
		eglTerminate(edisplay);
		xcb_disconnect(xdisplay);
		fatal("EGL failed to Initialize");
	}
	eglTerminate(edisplay);
	xcb_disconnect(xdisplay);
	return 0;
}

void fatal(char *msg)
{
	fprintf(stderr, "%s\n", msg);
	exit(1);
}

Sefaults at eglInitialize(). It doesn't if I replace all of the XCB calls with Xlib calls. Of course there's a good chance I'm doing it wrong...

Offline

Board footer

Powered by FluxBB