X 请求失败错误:BadMatch

发布于 2024-12-12 02:19:07 字数 1850 浏览 0 评论 0原文

我正在尝试执行一些“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

如果有任何进一步的想法,我将非常感激。

I'm trying to execute some "hello world" opengl code:

#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;
}

As a result I get:

  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

Here is the stack trace:

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 

Here is the last piece of code, after witch the program crashes:

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

"glXCreateContextAttribsARB" address is obtained successfully, but the program crashes on its invocation.

If I specify OpenGL version less than 4.2 in "glutInitContextVersion()" program runs without errors.

Here is my glxinfo's OpelGL version:

OpenGL version string: 4.2.0 NVIDIA 285.05.09

I would be very appreciate any further ideas.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文