VC2010 配置OpenGL环境

来源:互联网 发布:C语言send函数格式 编辑:程序博客网 时间:2024/06/05 05:47

1. 下载glut包:www.opengl.org 官网上下载, 里面包含了glut32.lib glut32.dll以及glut.h;

2、将glut.h放到C:/Program Files /Microsoft SDKs/Windows/v7.0AA/Include/gl目录下;glut32.lib放到C:/Program Files /Microsoft SDKs/Windows/v7.0A/Lib目录下;glut32.dll放到C:/WINDOWS/system32目录下

3、在VS2010中新建一个空工程,选择win32 console project

 

4. 向该工程添加一个.cpp文件,内容为以下内容:

#include "stdafx.h"

#include<gl/glut.h>

 

void myDisplay(void)

{

     glClear(GL_COLOR_BUFFER_BIT);

     glRectf(-0.5f, -0.5f, 0.5f, 0.5f);

     glFlush();

}

int _tmain(int argc, _TCHAR* argv[])

{

    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

    glutInitWindowPosition(100, 100);

    glutInitWindowSize(400, 400);

    glutCreateWindow("第一个OpenGL程序");

    glutDisplayFunc(&myDisplay);

    glutMainLoop();

     return 0;

}

5. 设置IDE环境:project->new Property->Configuration propertites->linker->Input->Additional dependencies

里面加入opengl32.lib glut32.lib这两个lib,应用、确定。

 

 

6. F5,start debugging,应该能看到一个窗口,中间区域为白色正方形。

原创粉丝点击