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

 时间:2026-05-18 20:07:04

1、新建一个控制台应用程序

2、将以下语句复制到主文件中

#include "stdafx.h"

#include <iostream>

#include<gl/glut.h>  

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、编译运行即可通过

  • Visual Studio 2019怎么创建桌面图标
  • VS如何开启解决方案资源管理器
  • vs怎么创建一个新的项目
  • vs写完代码怎么运行
  • Visual Studio 工作负荷怎么选择
  • 热门搜索
    怎么保护牙齿 沃尔沃xc60怎么样 新陈代谢不好怎么办 煤是怎么形成的 葡萄干怎么吃 四川师范大学怎么样 怎么样在网上赚钱 键盘上顿号怎么打 扁豆怎么做好吃 脱皮怎么办