【发布时间】:2016-07-07 14:39:53
【问题描述】:
我正在使用 Visual Studio 2013 和 OpenGL 创建模拟。 理想情况下,我正在创建的窗口应该保持打开状态,以便我可以使用键进行更改,并且可以在同一窗口上查看不同的结果。 但是窗口在启动后立即关闭并显示错误代码
program.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;
}
【问题讨论】:
-
STATUS_INVALID_CRUNTIME_PARAMETER - 可能是混合 crts 之类的,从源代码重建一切
-
@paulm 尝试重建。尝试清洁和重建。还是没有变化。它可能与windows或glut32.dll有关吗?因为我有段时间没改代码了,突然就开始这样了。
-
您仍然有一个
glEnd,但没有对应的glBegin。 -
@BDL 我删除了 glEnd。仍然没有变化。
-
你更新显卡驱动了吗?
标签: c++ visual-studio opengl