OpenGL 窗口立即关闭,并显示错误 -1073740777 (0xc0000417)
OpenGL window immediately closes with error -1073740777 (0xc0000417)
我正在使用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;
}
我对造成您麻烦的原因是,您使用的某些库是使用与您正在使用的编译器不同的编译器构建的,并且预期运行时的差异会给您带来一些麻烦。如果上面给出的最小程序崩溃,那么这是最可能的原因。
请注意,在代码中,对 glFinish
和 glFlush
的调用是多余的,因为缓冲区交换隐含了刷新和完成。此外,将显示函数注册为 GLUT 空闲处理程序通常不是一个好主意;注册 glutPost重新显示 如果您需要连续的显示更新。
问题与我的驱动程序有关。重新安装所有内容后,它工作正常。
我认为这是因为交换功能还取决于系统,而不仅仅是库。我在某处读到过。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 程序崩溃并显示"std::out_of_range"错误
- 显示错误输出的简单数组排序程序
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- 我是 c++ 的新手.学习基本知识后,我想做井字游戏.对于印刷板,我在下面写代码,但它显示错误
- Android NDK clang 编译器错误在 Windows 上显示'No such file or directory'
- Clion显示错误,但可以使用Cmake成功构建代码
- 代码使用向量成功运行,但使用数组显示错误
- 在链表中的第 n 位插入显示分割错误
- 为什么当 vector 为空时会显示运行时错误?
- 查找显示链表时出现的错误
- SDL 映像:无法打开映像,仅显示错误消息
- 为什么将指针重新分配给 1D 数组的 char 时显示错误,但 2D 数组工作正常?
- 与clang++一起使用的VS代码在构建良好的C++文件中显示错误
- 修复转换 IP 时inet_ntoa中的 Endianess 错误显示反转值
- g 编译选项,带有-STD = C 14编译错误显示Werror = C 11 -Compat
- 加载图像约500次后,此错误显示在Visual Studio Qimage:不记忆,返回空图像
- 为什么非unicode应用程序系统语言环境使Unicode字体具有错误显示的符号字符
- 当整数变量用于在 c++ 中声明数组大小时,错误显示为"Expression must have a const value"
- 在Qt错误显示:"Fault Module Name: Qt5Cored.dll"在win 7和调试时:"segmentation fault"在CentOS Linux和Win 7中