Deep Color support

Wolfgang Draxinger wdraxinger.maillist at draxit.de
Sun Apr 27 02:52:08 PDT 2014


On Sun, 27 Apr 2014 11:35:37 +0200
Wolfgang Draxinger
<wdraxinger.maillist at draxit.de> wrote:

> > Btw. weren't FBConfigs a GLX thing?
> 
> No, XRender actually; GLX just piggybacks on that.

Okay, that needs some explanation. While all functions that have
"FBConfig" in their name are part of GLX you actually have so use some
XRender functions to select the desired pixel format from the subset of
FBConfigs offered to you by GLX.

In my own OpenGL/GLX programs I use the following code for FBConfig
selection:

	fbconfigs =
            glXChooseFBConfig(
                Xdisplay, Xscreen, VisData,
	        &numfbconfigs);

	int need_alpha = 0;
        for(int i = 0; VisData[i] != None; i+=2) {
	    if( VisData[i] == GLX_ALPHA_SIZE
             && VisData[i+1] > 0 ) {
	        need_alpha = 1;
	        break;
	    }
	}

	fbconfig = 0;
	if( need_alpha ) {
	    for(int i = 0; i<numfbconfigs; i++) {
		visual = (XVisualInfo*)
	        glXGetVisualFromFBConfig(
	            Xdisplay, fbconfigs[i]);

	        if(!visual)
	            continue;

		pict_format =
	            XRenderFindVisualFormat(
	                Xdisplay,
		        visual->visual);

	        if(!pict_format)
		    continue;

		fbconfig = fbconfigs[i];
		if(pict_format->direct.alphaMask > 0) {
			break;
		}
	    }
	}
        else {
	    fbconfig = fbconfigs[0];
	}

	if(!fbconfig) {
		fatalError("No matching FB config found");
	}

It took me quite a while to figure out that glXChooseFBConfig returns a
superset of XRender visuals that you have to comb through in a second
search to select the subset with the desired properties (in this case
an alpha channel on the X11 backing store).


Regards,

Wolfgang




More information about the wayland-devel mailing list