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 工作负荷怎么选择
  • 热门搜索
    海南岛旅游价格 张家口天路旅游攻略 中国旅游业发展前景 理县旅游攻略 海涛旅游出境游 苏州西山旅游 厦门金门旅游 古徽州文化旅游区 公司组织旅游通知 昆明大理丽江旅游攻略