为什么glvChooseFBConfig与nvidia一直是NULL

时间:2014-05-19 17:17:08

标签: opengl x11 vala glx

下面是我正在玩的Vala程序的一些代码。它在Ubuntu 12.04 ATI机器上运行良好,但是当我切换到运行相同操作系统的Nvidia(8400M GS)机器时,我得到零fbConfigs并且从glXChooseFBConfig返回null。

为什么会发生这种情况?这是获取FB配置和VisualInfo以使用GLX创建OpenGL上下文的最佳方法,还是有不同的方式我应该这样做?

代码

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信息

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

1 个答案:

答案 0 :(得分:5)

列表中的一个属性看起来无效:

glAttrs += GLX_RGBA;
glAttrs += 1;

在我找到的文档(http://www.opengl.org/sdk/docs/man2/xhtml/glXChooseFBConfig.xml)中,GLX_RGBA未被列为glXChooseFBConfig()的有效属性之一。