在 visual studio 2008 express 中配置 OpenGL 开发环境

学习computer graphics或者进行游戏开发之前的准备工作,opengl的配置是第一步。在linux、unix以及Mac系统中,配置都较为简单,在windows中我们需要进行一系列的准备工作。下面是step by step的配置内容。本文是从Thought from my life中总结简化而来,尤其是修改了一些opengl库的获取方式。

 

一、Download

OpenGL库文件:

1,freeglut from the freeglut SourceForge page.

2,original GLUT from Nate Robins' site.

 

Visual Studio 2008 Express的下载安装问题请见《OpenCV入门一:安装配置(with VC++ 2008/2010 Express)》。

 

二、编译freeglut

freeglut压缩包下载解压之后,只有部分include里面的头文件,此时需要用visual studio 2008进行编译:

1.上步骤1生成的 freeglut-2.6.0->include->GL 中有我们需要的freeglut.h,freeglut_ext.h,freeglut_std.h,glut.h

2.上步骤1生成的 freeglut-2.6.0->VisualStudio2008中,运行freeglut.sln,直接进行编译。在生成的Release或者Debug文件夹中,有我们需要的freeglut.lib和freeglut.dll

3.上步骤2生成的glut-3.7.6-bin包中,有我们需要的glut32.dll,glut32.lib。(注意,这个里面的glut.h不要)

4.拷贝需要的文件到对应系统文件夹中

  1. Copy all the .h files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\GL folder. This should be glut.h, freeglut.h, freeglut_ext.h, and freeglut_std.h.
  2. Copy all the .lib files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Libfolder. This should be freeglut.lib and glut32.lib.
  3. Copy all the .dll files into the C:\Windows\system32 folder. This should befreeglut.dll and glut32.dll.

注意:其中的C:\Program Files\Microsoft SDKs\Windows\v6.1 文件路径取决于你安装的Visual Studio 2008和SDK,也可能是V6.0。

5.建立新的工程和空的cpp文件

6.配置工程文件属性

  1. Click on Project -> [project name] Properties.
  2. Expand Configuration Properties.
  3. In the Configuration dropdown, select All Configurations.
  4. Select Linker -> Input.
  5. In the Additional Dependencies field, enter in GlU32.Lib OpenGL32.Lib freeglut.lib glut32.lib. Then click OK.

7.在空cpp中输入代码

#include<GL/glut.h>


void mydisplay(){
 glClear(GL_COLOR_BUFFER_BIT);
 glBegin(GL_POLYGON);
  glVertex2f(-0.5, -0.5);
  glVertex2f(-0.5, 0.5);
  glVertex2f(0.5, -0.5);
  glVertex2f(0.5, -0.5);
 glEnd();
 glFlush();
}

int main(int argc, char** argv){
 glutInit(&argc, argv);
 glutCreateWindow("Simple");
 glutDisplayFunc(mydisplay);
 glutMainLoop();
}

8.编译该工程,出现图形窗口显示。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值