多语言展示
当前在线:153今日阅读:176今日分享:34

fatal error C1083: 无法打开包括文件:stdafx.h

stdafx是标准应用程序框架的扩展,即Standard Application Framework Extensions的简写,它是与预编译文件*.pch相关联的。一般MFC程序文件的第一句都为:#include 'stdafx.h'。我们要注意的一点就是:#include 'stdafx.h'之前的所有代码都会被忽略,因此我们在编写VS程序时这段代码应该放在首句,否则其他的头文件将会被忽略执行以出现这样的错误fatal error C1083: 无法打开包括文件: “stdafx.h”: No such file or directory
工具/原料

Visual Studio 2010或2012、2013

方法/步骤
1

新建一个控制台应用程序

2

将以下语句复制到主文件中#include 'stdafx.h'#include #include  using namespace std;void renderScene(void){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_TRIANGLES); glVertex3f(-0.5, -0.5, 0.0); glVertex3f(0.5, 0.0, 0.0); glVertex3f(0.0, 0.5, 0.0); glEnd(); glutSwapBuffers();}int _tmain(int argc, _TCHAR* argv[]){ glutInit(&argc, (char**)argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100, 100); glutInitWindowSize(320, 320); glutCreateWindow('Hello OpenGL'); glutDisplayFunc(renderScene); glutMainLoop();//enters the GLUT event processing loop.   system('pause'); return 0;}

3

编译运行即可通过

推荐信息