Windows 7 Visual Studio 2008配置OpenGL开发环境

来源:互联网 发布:公交查询什么软件好用 编辑:程序博客网 时间:2024/05/22 08:01

【0.说明】巨简单,一般操作系统的openGL库已经有了,你只需要添加几个配置文件就行了
【1.glut下载(配置文件)】 http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip    
【2.系统配置】
glut.h ---> C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl(或者C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl) 
glut.dll,glut32.dll ---> C:\Windows\SysWOW64 (windows7 64位操作系统)                     
                    ---> C:\Windows\System32 (windows7 32位操作系统)  
【3.编译环境配置】
glut.lib,glut32.lib ---> D:\Program Files\Microsoft Visual Studio 9.0\VC\lib 
【4.测试】
打开vs2010(2008),新建一个项目。 选择 project->project property-> Configuration Properties->Linker->Input->Additional Dependencies 在其中添加opengl32.lib glu32.lib glut32.lib   在工程中添加如下代码即可。
 // glExampl0.cpp : 定义控制台应用程序的入口点。
//


#include "stdafx.h"
#include <Gl\glut.h>
void myDisplay(void){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2i(180,15);
glVertex2i(10,145);
glEnd();
glRectf(-0.5f,-0.5f,0.5f,0.5f);
glFlush();
}
void init(void){
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,200.0,0.0,150.0);
}
int _tmain(int argc, _TCHAR* argv[])
{
//glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_RGB| GLUT_SINGLE);
glutInitWindowPosition(50,100);
glutInitWindowSize(400,300);
glutCreateWindow("OpenGL");
init();
glutDisplayFunc(&myDisplay);
       glutMainLoop();
return 0;

}











0 0