项目名->管理NuGet程序包->浏览->搜索nupengl,下载安装即可。
参考博客:https://blog.csdn.net/HY_JT/article/details/79482556
还可以参考博客:https://blog.csdn.net/yinglang19941010/article/details/50166343
#include <cstdio>
#include <GL/glew.h>
#include <GL/freeglut.h>#pragma comment(lib, "glew32.lib")void displayFunction()
{glClear(GL_COLOR_BUFFER_BIT);glRectf(-0.5, -0.5, 0.5, 0.5);glColor3f(0.0, 1.0, 0.0);glFlush();
};int main(int argc, char *argv[])
{glutInit(&argc, argv);glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);glutInitWindowSize(600, 600);glutCreateWindow("The first OpenGL Application");glewExperimental = true;glewInit();printf("OpenGL version: (%s) \n", glGetString(GL_VERSION));glutDisplayFunc(&displayFunction);glutMainLoop();return 0;
}
运行结果: