问题
I'm trying to configure a framebuffer on a computer which has no dedicated graphics card. Only mesa GL.
I've tried multiple FB configurations but I can't seem to get a non-NULL return. The same code works on another computer with nvidia drivers..
OpenGL vendor string: Tungsten Graphics Inc
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Desktop
OpenGL version string: 3.0 Mesa 8.0.4
OpenGL shading language version string: 1.30
The mesa examples that works on another computer also fails at the same glXFBConfig line.
Here's the relevant part of the code
int fbAttribs[] = {
None
};
int numberOfFramebufferConfigurations = 0;
GLXFBConfig* fbConfigs = glXChooseFBConfig(self->display, DefaultScreen(self->display), fbAttribs, &numberOfFramebufferConfigurations);
As I said, I tried with different configurations such as:
int fbAttribs[NUM_FB_CONFIGS][100] = {
{
/* Single buffered, with depth buffer */
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_DOUBLEBUFFER, 0,
GLX_STENCIL_SIZE, 0,
None
},
{
/* Double buffered, with depth buffer */
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_DOUBLEBUFFER, 1,
GLX_STENCIL_SIZE, 0,
None
},
{
/* Single buffered, without depth buffer */
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 0,
GLX_DOUBLEBUFFER, 0,
GLX_STENCIL_SIZE, 0,
None
},
{
/* Double buffered, without depth buffer */
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 0,
GLX_DOUBLEBUFFER, 1,
GLX_STENCIL_SIZE, 0,
None
}
};
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 0,
GLX_DOUBLEBUFFER, 1,
GLX_STENCIL_SIZE, 0,
None
}
};
回答1:
Did you check, that GLX
is actually available? Also for glXChooseFBConfig to work the server must support the Render
extension. Both GLX
and Render
are widely supported these days. But they may not, so you have to check. Use glXQueryExtension
to check for GLX and XRenderQueryExtension
to check for Render
.
回答2:
Answering my own question with the solution.
This actually ended up being the OpenGL context not supporting the required extensions. In this case, I was ssh'ing (with -X) into the machine and running the binary that does all the OpenGL computation. In such cases the hosts or the client's OpenGL may be used depending on the $DISPLAY variable. Setting the DISPLAY variable to :0.0 meant use the host's OpenGL, which solved the problems.
来源:https://stackoverflow.com/questions/19393333/glxchoosefbconfig-returns-null