X请求失败的错误:BadMatch

时间:2011-10-25 21:22:23

标签: opengl linux nvidia

我正在尝试执行一些“hello world”opengl代码:

#include <GL/freeglut.h>

void displayCall() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);
    ... Some more code here
    glutSwapBuffers();
} 

int main(int argc, char *argv[]) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(300, 200);
    glutInitContextVersion(4, 2);
    glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
    glutCreateWindow("Hello World!");
    glutDisplayFunc(displayCall);
    glutMainLoop();
    return 0;
}

结果我得到了:

  X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  128 (GLX)
  Minor opcode of failed request:  34 ()
  Serial number of failed request:  39
  Current serial number in output stream:  40

这是堆栈跟踪:

fghCreateNewContext() at freeglut_window.c:737 0x7ffff7bbaa81   
fgOpenWindow() at freeglut_window.c:878 0x7ffff7bbb2fb  
fgCreateWindow() at freeglut_structure.c:106 0x7ffff7bb9d86 
glutCreateWindow() at freeglut_window.c:1,183 0x7ffff7bbb4f2    
main() at AlphaTest.cpp:51 0x4007df 

这是程序崩溃之后的最后一段代码:

createContextAttribs = 
  (CreateContextAttribsProc) fghGetProcAddress("glXCreateContextAttribsARB" );
if ( createContextAttribs == NULL ) {
    fgError( "glXCreateContextAttribsARB not found" );
}
context = createContextAttribs( dpy, config, share_list, direct, attributes );

“glXCreateContextAttribsARB”地址已成功获取,但程序在其调用时崩溃。

如果我在“glutInitContextVersion()”中指定的OpenGL版本小于4.2,则程序运行时没有错误。

这是我的glxinfo的OpelGL版本:

OpenGL version string: 4.2.0 NVIDIA 285.05.09

我非常感谢任何进一步的想法。

1 个答案:

答案 0 :(得分:0)

我认为我有类似的问题。

如果我指定3.3,它会加载并显示

OpenGL Version: 3.3.0 NVIDIA 280.10.01.04

另一方面,如果我尝试4.0,我会看到这个错误:

X Error of failed request:  BadAlloc (insufficient resources for operation)
  Major opcode of failed request:  135 (GLX)
  Minor opcode of failed request:  34 ()
  Serial number of failed request:  39
  Current serial number in output stream:  40

我尝试更新驱动程序,但后来我发现我的显卡不支持OpenGL 4.

所以我尝试用另一个问题回答你:你确定你的卡支持4.2吗?

检查兼容性:

http://developer.nvidia.com/opengl-driver