gpt4 book ai didi

opengl - X失败的请求: BadMatch错误

转载 作者:太空狗 更新时间:2023-10-29 11:22:59 25 4
gpt4 key购买 nike

我正在尝试执行一些“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()”中指定小于4.2的OpenGL版本,程序将运行而不会出现错误。

这是我的glxinfo的OpelGL版本:
OpenGL version string: 4.2.0 NVIDIA 285.05.09

我将不胜感激任何进一步的想法。

最佳答案

我想我也有类似的问题。

如果我指定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

关于opengl - X失败的请求: BadMatch错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8190380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com