我最近将我的电脑升级到了Windows 10,并安装了Visual Studio 2015。我试图在Visual Studio 2015中编写一个“Hello OpenGL”程序,项目已经成功构建,但是它以代码1退出。我得到的只是创建的窗口很快就出现并消失了。以下是我的代码:
#include <GL\glew.h>
#include <GL\freeglut.h>
#include <iostream>
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(800, 600);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello OpenGL");
glutMainLoopEvent();
return 0;
}
如我之前所提到的,该项目已成功构建,以下是构建结果:
1>------ Build started: Project: HelloGL, Configuration: Debug Win32 ------
1> main.cpp
1> HelloGL.vcxproj -> D:\OpenGL Projects\HelloGL\Debug\HelloGL.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
但是当我按下F5
调试程序时,结果却让我感到沮丧:
The thread 0x23d4 has exited with code 1 (0x1).
The thread 0x20b8 has exited with code 1 (0x1).
The thread 0x10d0 has exited with code 1 (0x1).
The program '[7040] HelloGL.exe' has exited with code 1 (0x1).
glutMainLoopEvent()
处设置断点,这会产生一个控制台窗口和一个普通窗口,所以我猜问题出在'gutMainLoopEvent()'上。 - dulq