您的位置:首页 > 运维架构

VC6.0下配置opengl

2012-02-29 09:22 190 查看
为了完成《计算机图形学》课程最后大作业,即写一篇和图形学相关的报告就行,老师的要求放的相当宽。这样选题也就比较方便了,由于自己一直对3D游戏比较感兴趣,所以下载了一个3D坦克对战的游戏源代码,准备用几天时间彻底的分析一下。

计算机图形学这个课程比较侧重于理论,SIGGRAHP的论文一节课介绍一个实在让人有点吃不消。急需加强的数学功底,确实本该交一篇理论性很强的报告,而自己有点贪玩,最后还是禁不住游戏的诱惑。
下载的这个游戏的名称为《Hufo_Tank2》,在XP(或者以前)用VC6.0开发(顺便提一句:广大用户玩的魔兽世界魔兽争霸都是在VC6.0下开发的~~)。本想移植到WIN7的VS2010下,结果发现冲突的太多。所以又重新安装了VC6.0。在WIN7下安装一个兼容的VC6.0还是很费事的,感谢在buaabt上贡献WIN7下兼容版本的VC6.0的闫建宇(你那惊人的下载量让我望尘莫及啊~)。
我将VC6.0安装在D:\Program Files\VC6\下,安装好了之后就是配置一下opengl。将配置过程记录在这里,以后需要配置的时候也方便点(假设你已经在机器上安装了兼容版本的VC6.0),另外,以下以我安装的目录D:\Program Files\VC6\为例进行说明。

Step1:点击链接http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip 下载OpenGL文件

Step2:配置OpenGL文件
1) 解压glutdlls37beta.zip.将得到三类文件。第一类是动态链接库文件(.dll):glut.dll,glut32.dll;第二类是头文件(.h):glut.h;第三类是库文件(.lib):glut.lib,glut32.lib;共有5个文件;
2) 将动态链接库文件glut.dll,glut32.dll,全部拷贝到C:/WINDOWS/system/目录下以及C:/WINDOWS/system32/目录下;
3) 将头文件glut.h,全部拷贝到D:\Program Files\VC6\Microsoft Visual Studio\VC98\Include\GL\目录下。如果没有GL目录,新创建一个文件夹命名为GL;
4) 将库文件glut.lib,glut32.lib,全部拷贝到D:\Program Files\VC6\Microsoft Visual Studio\VC98\Lib目录下;

Step3:配置VC6.0项目属性
1) 启动VC 6,新建一个Win32 Console Application项目
2) 依次选择菜单栏的Project → Settings → Link选项卡
3) 在Object/library modules下面的文本框的最前面添加如下库文件内容:Opengl32.lib glut32.lib GLAUX.LIB Glu32.lib
4) 在Project Options中修改subsystem:console修改为subsystem:windows。
5) 依次选择:Project → Settings → C/C++选项卡
6) 在Preprocessor definitions 中的_CONSOLE修改为_WINDOWS。
7) 如果你安装的目录不是默认目录,比如我的目录就不是默认目录。你还需要接着完成以下几步:
8) 依次选择Tools → Options → Directories选项卡,在右侧的“show directories for”下拉框中选择“Include files”.在下方的directories中添加一个新的头文件引用路径:D:\PROGRAM FILES\VC6\MICROSOFT VISUAL STUDIO\VC98\INCLUDE.
9) 在右侧的“show directories for”下拉框中选择“Library files”。在下方的directories中添加一个新的库引用路径:D:\PROGRAM FILES\VC6\MICROSOFT VISUAL STUDIO\VC98\LIB

Step4:用以下代码测试一下(代码来自Nehe的红宝书):

/*

* Copyright (c) 1993-1997, Silicon Graphics, Inc.

* ALL RIGHTS RESERVED

* Permission to use, copy, modify, and distribute this software for

* any purpose and without fee is hereby granted, provided that the above

* copyright notice appear in all copies and that both the copyright notice

* and this permission notice appear in supporting documentation, and that

* the name of Silicon Graphics, Inc. not be used in advertising

* or publicity pertaining to distribution of the software without specific,

* written prior permission.

*

* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"

* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,

* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR

* FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON

* GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,

* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY

* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,

* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF

* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN

* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON

* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE

* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.

*

* US Government Users Restricted Rights

* Use, duplication, or disclosure by the Government is subject to

* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph

* (c)(1)(ii) of the Rights in Technical Data and Computer Software

* clause at DFARS 252.227-7013 and/or in similar or successor

* clauses in the FAR or the DOD or NASA FAR Supplement.

* Unpublished-- rights reserved under the copyright laws of the

* United States.  Contractor/manufacturer is Silicon Graphics,

* Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.

*

* OpenGL(R) is a registered trademark of Silicon Graphics, Inc.

*/

/*

* hello.c

* This is a simple, introductory OpenGL program.

*/

#include <GL/glut.h>

void display(void)

{

/* clear all pixels  */

glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at

* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)

*/

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();

/* don't wait!

* start processing buffered OpenGL routines

*/

glFlush ();

}

void init (void)

{

/* select clearing color    */

glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values  */

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

}

/*

* Declare initial window size, position, and display mode

* (single buffer and RGBA).  Open window with "hello"

* in its title bar.  Call initialization routines.

* Register callback function to display graphics.

* Enter main loop and process events.

*/

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;   /* ANSI C requires main to return int. */

}

如果能够正常弹出一个框表示没有问题了。本文出自 “相信并热爱着” 博客,请务必保留此出处http://hipercomer.blog.51cto.com/4415661/792430
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: