VC6.0下配置opengl

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

计算机图形学这个课程比较侧重于理论,SIGGRAHP的论文一节课介绍一个实在让人有点吃不消。急需加强的数学功底,确实本该交一篇理论性很强的报告,而自己有点贪玩,最后还是禁不住游戏的诱惑。

下载的这个游戏的名称为《Hufo_Tank2》,在XP(或者以前)用VC6.0开发(顺便提一句:广大用户玩的魔兽世界魔兽争霸都是在VC6.0下开发的~~)。本想移植到WIN7VS2010下,结果发现冲突的太多。所以又重新安装了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.dllglut32.dll;第二类是头文件(.h)glut.h;第三类是库文件(.lib)glut.libglut32.lib;共有5个文件;

2)        将动态链接库文件glut.dllglut32.dll,全部拷贝到C:/WINDOWS/system/目录下以及C:/WINDOWS/system32/目录下;

3)        将头文件glut.h,全部拷贝到D:\Program Files\VC6\Microsoft Visual Studio\VC98\Include\GL\目录下。如果没有GL目录,新创建一个文件夹命名为GL

4)        将库文件glut.libglut32.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的红宝书):


 
 
  1. /* 
  2.  
  3.  * Copyright (c) 1993-1997, Silicon Graphics, Inc. 
  4.  
  5.  * ALL RIGHTS RESERVED 
  6.  
  7.  * Permission to use, copy, modify, and distribute this software for 
  8.  
  9.  * any purpose and without fee is hereby granted, provided that the above 
  10.  
  11.  * copyright notice appear in all copies and that both the copyright notice 
  12.  
  13.  * and this permission notice appear in supporting documentation, and that 
  14.  
  15.  * the name of Silicon Graphics, Inc. not be used in advertising 
  16.  
  17.  * or publicity pertaining to distribution of the software without specific, 
  18.  
  19.  * written prior permission. 
  20.  
  21.  * 
  22.  
  23.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" 
  24.  
  25.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, 
  26.  
  27.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR 
  28.  
  29.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON 
  30.  
  31.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, 
  32.  
  33.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY 
  34.  
  35.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, 
  36.  
  37.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF 
  38.  
  39.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN 
  40.  
  41.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON 
  42.  
  43.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE 
  44.  
  45.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. 
  46.  
  47.  * 
  48.  
  49.  * US Government Users Restricted Rights 
  50.  
  51.  * Use, duplication, or disclosure by the Government is subject to 
  52.  
  53.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph 
  54.  
  55.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software 
  56.  
  57.  * clause at DFARS 252.227-7013 and/or in similar or successor 
  58.  
  59.  * clauses in the FAR or the DOD or NASA FAR Supplement. 
  60.  
  61.  * Unpublished-- rights reserved under the copyright laws of the 
  62.  
  63.  * United States.  Contractor/manufacturer is Silicon Graphics, 
  64.  
  65.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311. 
  66.  
  67.  * 
  68.  
  69.  * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. 
  70.  
  71.  */ 
  72.  
  73.   
  74.  
  75. /* 
  76.  
  77.  * hello.c 
  78.  
  79.  * This is a simple, introductory OpenGL program. 
  80.  
  81.  */ 
  82.  
  83. #include <GL/glut.h> 
  84.  
  85.   
  86.  
  87. void display(void
  88.  
  89.  
  90. /* clear all pixels  */ 
  91.  
  92.    glClear (GL_COLOR_BUFFER_BIT); 
  93.  
  94.   
  95.  
  96. /* draw white polygon (rectangle) with corners at 
  97.  
  98.  * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)  
  99.  
  100.  */ 
  101.  
  102.    glColor3f (1.0, 1.0, 1.0); 
  103.  
  104.    glBegin(GL_POLYGON); 
  105.  
  106.       glVertex3f (0.25, 0.25, 0.0); 
  107.  
  108.       glVertex3f (0.75, 0.25, 0.0); 
  109.  
  110.       glVertex3f (0.75, 0.75, 0.0); 
  111.  
  112.       glVertex3f (0.25, 0.75, 0.0); 
  113.  
  114.    glEnd(); 
  115.  
  116.   
  117.  
  118. /* don't wait!  
  119.  
  120.  * start processing buffered OpenGL routines 
  121.  
  122.  */ 
  123.  
  124.    glFlush (); 
  125.  
  126.  
  127.   
  128.  
  129. void init (void
  130.  
  131.  
  132. /* select clearing color    */ 
  133.  
  134.    glClearColor (0.0, 0.0, 0.0, 0.0); 
  135.  
  136.   
  137.  
  138. /* initialize viewing values  */ 
  139.  
  140.    glMatrixMode(GL_PROJECTION); 
  141.  
  142.    glLoadIdentity(); 
  143.  
  144.    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 
  145.  
  146.  
  147.   
  148.  
  149. /* 
  150.  
  151.  * Declare initial window size, position, and display mode 
  152.  
  153.  * (single buffer and RGBA).  Open window with "hello" 
  154.  
  155.  * in its title bar.  Call initialization routines. 
  156.  
  157.  * Register callback function to display graphics. 
  158.  
  159.  * Enter main loop and process events. 
  160.  
  161.  */ 
  162.  
  163. int main(int argc, char** argv) 
  164.  
  165.  
  166.    glutInit(&argc, argv); 
  167.  
  168.    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
  169.  
  170.    glutInitWindowSize (250, 250); 
  171.  
  172.    glutInitWindowPosition (100, 100); 
  173.  
  174.    glutCreateWindow ("hello"); 
  175.  
  176.    init (); 
  177.  
  178.    glutDisplayFunc(display); 
  179.  
  180.    glutMainLoop(); 
  181.  
  182.    return 0;   /* ANSI C requires main to return int. */ 
  183.  

如果能够正常弹出一个框表示没有问题了。

本文出自 “相信并热爱着” 博客,请务必保留此出处http://hipercomer.blog.51cto.com/4415661/792430

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值