Jason Smith
Jason Smith

Reputation: 765

Why is glXChooseFBConfig always NULL with nvidia

Below is some code for a Vala program I am playing around with. It works well on an Ubuntu 12.04 ATI machine, but when I switch to a Nvidia (8400M GS) machine running the same OS I get zero fbConfigs and null is returned from glXChooseFBConfig.

Why might this be happening? Is this the best way to get the FB config and VisualInfo for creating an OpenGL context with GLX or is there a different way I should be doing it?

Code

int errorBase;
int eventBase;
int[] glAttrs;
int[] attrs;
FBConfig* fbConfig;

x_server = xServer;
if (screen == int.MIN)
{
    screen = x_server.default_screen().screen_number_of_screen();
}
message("Creating Linux context.");

if (glXQueryExtension(x_server, out errorBase, out eventBase) == false)
{
    error("GLX extension is not supported.");
}

if (x_server.render_query_extension(out errorBase, out eventBase) ==
    false)
{
    error("X11 Render extension is not available.");
}

// Get the visual information for this window
// so OpenGL has what it needs.
glAttrs = new int[0];
glAttrs += GLX_X_RENDERABLE;
glAttrs += 1;
glAttrs += GLX_DRAWABLE_TYPE;
glAttrs += GLX_WINDOW_BIT;
glAttrs += GLX_RENDER_TYPE;
glAttrs += GLX_RGBA_BIT;
glAttrs += GLX_X_VISUAL_TYPE;
glAttrs += GLX_TRUE_COLOR;
glAttrs += GLX_DOUBLEBUFFER;
glAttrs += 1;
glAttrs += GLX_RGBA;
glAttrs += 1;
glAttrs += GLX_RED_SIZE;
glAttrs += 8;
glAttrs += GLX_GREEN_SIZE;
glAttrs += 8;
glAttrs += GLX_BLUE_SIZE;
glAttrs += 8;
glAttrs += GLX_ALPHA_SIZE;
glAttrs += 8;
glAttrs += GLX_DEPTH_SIZE;
glAttrs += 24;
glAttrs += GLX_STENCIL_SIZE;
glAttrs += 8;
glAttrs += (int)None;


fbConfig = glXChooseFBConfig(x_server, screen,
                             glAttrs, out numConfigs);
message("Retreived %d FB configs.", numConfigs);
return_if_fail(fbConfig != null);

visual_info = glXGetVisualFromFBConfig(x_server, fbConfig[0]);
return_if_fail(visual_info != null);

GLX Info

204 GLX Visuals
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x021 24 tc  0  32  0 r  y .   8  8  8  0 .  s  4 24  8 16 16 16 16  0 0 None
0x022 24 dc  0  32  0 r  y .   8  8  8  0 .  s  4 24  8 16 16 16 16  0 0 None
0x024 24 tc  0  32  0 r  y .   8  8  8  8 .  s  4 24  8 16 16 16 16  0 0 None
0x025 24 tc  0  32  0 r  . .   8  8  8  0 .  s  4 24  8 16 16 16 16  0 0 None
0x026 24 tc  0  32  0 r  . .   8  8  8  8 .  s  4 24  8 16 16 16 16  0 0 None
0x027 24 tc  0  32  0 r  y .   8  8  8  0 .  s  4 24  0 16 16 16 16  0 0 None
0x028 24 tc  0  32  0 r  y .   8  8  8  8 .  s  4 24  0 16 16 16 16  0 0 None
0x029 24 tc  0  32  0 r  . .   8  8  8  0 .  s  4 24  0 16 16 16 16  0 0 None
0x02a 24 tc  0  32  0 r  . .   8  8  8  8 .  s  4 24  0 16 16 16 16  0 0 None

Upvotes: 1

Views: 1312

Answers (1)

Reto Koradi
Reto Koradi

Reputation: 54642

One of the attributes in your list looks invalid:

glAttrs += GLX_RGBA;
glAttrs += 1;

In the documentation I found (http://www.opengl.org/sdk/docs/man2/xhtml/glXChooseFBConfig.xml), GLX_RGBA is not listed as one of the valid attributes for glXChooseFBConfig().

Upvotes: 5

Related Questions