I have an application that uses the GLX extension texture_from_pixmap
, which requires a color buffer created using an FBConfig with GLX_BIND_TO_TEXTURE_RGB_EXT, or GLX_BIND_TO_TEXTURE_RGBA_EXT, per the spec.
Only a color buffer of a GLX pixmap created using an FBConfig with attribute GLX_BIND_TO_TEXTURE_RGB_EXT or GLX_BIND_TO_TEXTURE_RGBA_EXT set to TRUE can be bound as a texture.
https://www.khronos.org/registry/OpenGL/extensions/EXT/GLX_EXT_texture_from_pixmap.txt
My application does this, and works fine with Mesa and the Intel i965 driver, but not with the proprietary Nvidia driver.
When using glXChooseFBConfig with the Nvidia driver, no matching FBConfigs are returned, and I can't seem to figure out why.
I've made a minimal code sample that reproduces this problem.
#include <stdio.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
int main()
{
Display *display = XOpenDisplay(NULL);
if (!display) {
printf("Unable to connect to display.\n");
return 1;
}
int pixmap_config[] = {
GLX_BIND_TO_TEXTURE_RGB_EXT, True,
GLX_NONE
};
int c = 0;
GLXFBConfig *configs = glXChooseFBConfig(display, 0, pixmap_config, &c);
if (!configs) {
printf("No appropriate GLX FBConfig available!\n");
} else {
printf("Number of matching configs: %i\n", c);
}
return 0;
}
On any Nvidia graphics card I test using the proprietary driver, I get:
No appropriate GLX FBConfig available!
Using Intel Graphics with Mesa, I get:
Number of matching configs: 82
What am I doing wrong here?
To quote the spec:
attrib_list
Specifies a list of attribute/value pairs. The last attribute must be None.
Some GL implementations, such as Mesa, are more permissive, and will accept GLX_NONE
(0x8000) terminating this list of attributes. However, the Nvidia driver does not, and will return NULL. Specifying Xlib's None
(0) works. This is also the case for glXCreatePixmap
.