来自OpenGL的X11 BadAlloc错误

来自OpenGL的X11 BadAlloc错误,c,opengl,x11,C,Opengl,X11,我正在学习使用OpenGL。我正在尝试运行第一个示例,它是。它可以很好地编译,但当我尝试运行它时,会出现X11 BadAlloc错误: X Error of failed request: BadAlloc (insufficient resources for operation) Major opcode of failed request: 128 (GLX) Minor opcode of failed request: 34 () Serial number of failed

我正在学习使用OpenGL。我正在尝试运行第一个示例,它是。它可以很好地编译,但当我尝试运行它时,会出现X11 BadAlloc错误:

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

据我所知,这个错误是在调用glutCreateWindow时引起的。我不知道这是X本身的问题还是我的图形卡(nVidia geForce 310)的问题

您的图形驱动程序不支持OpenGL 4.0版

glutInitContextVersion(4, 0);
我将其更改为3.3:

glutInitContextVersion(3, 3);

而且效果很好。您可以从
glxinfo
获取OpenGL版本。非常感谢。这是有道理的。我想我会看看我能做些什么使它兼容…这通常归结为更新你的驱动程序。如果这不起作用,你就无能为力了。但无论如何,坚持3.3;如果你是初学者,4.0不会给你带来很多。