OpenGL + VS2015 + Windows10配置

官网下载OpenGL:https://www.opengl.org/resources/libraries/glut/

解压后得到5个文件:glut.h,glut.dll,glut32.dll,glut.lib,glut32.lib。

打开VS2015安装目录,在【VC/include/】下新建一个文件夹,名为GL,把gl.h文件复制其中;

找到【VC/lib】,把glut.lib,glut32.lib复制其中;

复制glut.dll和glut32.dll到系统的dll目录下:C:\Windows\system32文件夹内(32位系统)或‪C:\Windows\SysWOW64(64位系统)。

配置完成,接下来程序测试。

#include <GL/glut.h>
 
void myDisplay(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
    glFlush();
}
 
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(400, 400);
    glutCreateWindow("第一个OpenGL程序");
    glutDisplayFunc(&myDisplay);
    glutMainLoop();
    return 0;
}

运行如下:

猜你喜欢

转载自www.cnblogs.com/MagicAsa/p/9243534.html