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

 时间:2026-02-15 15:49:35

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 工作负荷怎么选择
  • 热门搜索
    如何设置打印机 mcafee怎么样 如何安装马桶 皮鞋上的油渍怎么去除 外蒙古旅游 重启路由器 湿气重的表现怎么调理 儿童龋齿怎么治疗 成都旅游指南 旅游天地