vs2013下OpenGL环境的配置
1、下载glut库:https://files.cnblogs.com/files/laoxia/glutdlls37beta.zip
2、解压后,将glut.lib和glut32.lib两个文件拷贝到X:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib 目录下;
3、将文件glut.dll 和 glut32.dll拷贝到C:\Windows\system32文件夹内(32位系统)或C:\Windows\SysWOW64(64位系统)下;
4、将头文件 glut.h 拷贝到 X:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\GL 下;
5、编写Demo并编译运行:
#include <GL/glut.h>
#include <stdlib.h>
void display(void)
{
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush ();
}
void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}