1

下面是我正在玩的 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
4

1 回答 1

5

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

glAttrs += GLX_RGBA;
glAttrs += 1;

在我找到的文档中(http://www.opengl.org/sdk/docs/man2/xhtml/glXChooseFBConfig.xml),GLX_RGBA没有列为glXChooseFBConfig().

于 2014-05-20T03:48:56.580 回答