OpenGL 窗口立即关闭,并显示错误 -1073740777 (0xc0000417)

OpenGL window immediately closes with error -1073740777 (0xc0000417)

本文关键字:错误 显示 -1073740777 0xc0000417 窗口 OpenGL      更新时间:2023-10-16

我正在使用Visual Studio 2013和OpenGL来创建模拟。理想情况下,我正在创建的窗口应保持打开状态,以便我可以使用键进行更改,并且可以在同一窗口中查看不同的结果。但是窗口在启动后立即关闭并显示错误代码

程序.exe' 已退出,代码为 -1073740777 (0xc0000417)

我做了一些调试并尝试对各种行进行注释,发现如果我将"glutSwapBuffers()"作为注释,窗口将保持打开状态但为空。

有人可以对此有所了解吗?

void keyboard (unsigned char key, int x, int y)
{
 switch (key)
 {
    case 'r': case 'R':
    if (filling==0)
    {
        glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 
        filling=1;
    }
    else
    {
        glPolygonMode (GL_FRONT_AND_BACK, GL_POINT); 
        filling=0;
    }
    break;
    case 27:
    exit(0);
    break;
 }
}

.

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); 
glRotatef(-90,0.0,1.0,0.0); 
glRotatef(-90,1.0,0.0,0.0); 
rotation_x = rotation_x + (rotation_x_increment - rotation_x)/50;
rotation_y = rotation_y + (rotation_y_increment - rotation_y)/50;
rotation_z = rotation_z + rotation_z_increment;
if (rotation_x > 359) rotation_x = 0;
if (rotation_y > 359) rotation_y = 0;
if (rotation_z > 359) rotation_z = 0;
if(rotation_x_increment > 359) rotation_x_increment = 0;
if(rotation_y_increment > 359) rotation_y_increment = 0;
if(rotation_z_increment > 359) rotation_z_increment = 0;
glRotatef(rotation_x,1.0,0.0,0.0); 
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);
glTranslatef(x_translate,0.0,0.0);
glTranslatef(0.0,y_translate,0.0);
glTranslatef(0,0,z_translate); 
glFlush(); // This force the execution of OpenGL commands
glutSwapBuffers(); 
glFinish();
}

.

int main(int argc, char **argv)
{
IntroDisplay();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(screen_width,screen_height);
glutInitWindowPosition(0,0);
glutCreateWindow("Ultrasonic Testing");
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc (resize);
glutKeyboardFunc (keyboard);
glutSpecialFunc (keyboard_s);
glutMouseFunc(mouse);
glutMotionFunc(mouseMove);
init();
glutMainLoop();
return 0;
}

您是否尝试编译和运行一个绝对最小的裸露程序,该程序除了使用 GLUT 创建一个窗口、注册一个仅清除和交换缓冲区的显示函数之外什么都不做,仅此而已。 即这个

#include <GL/glut.h>
static void display(void)
{
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutCreateWindow("test");
    glutDisplayFunc(display);
    glutIdleFunc(glutPostRedisplay);
    glutMainLoop();
    return 0;
}

我对造成您麻烦的原因是,您使用的某些库是使用与您正在使用的编译器不同的编译器构建的,并且预期运行时的差异会给您带来一些麻烦。如果上面给出的最小程序崩溃,那么这是最可能的原因。

请注意,在代码中,对 glFinishglFlush 的调用是多余的,因为缓冲区交换隐含了刷新和完成。此外,将显示函数注册为 GLUT 空闲处理程序通常不是一个好主意;注册 glutPost重新显示 如果您需要连续的显示更新。

问题与我的驱动程序有关。重新安装所有内容后,它工作正常。

我认为这是因为交换功能还取决于系统,而不仅仅是库。我在某处读到过。

相关文章: