資源簡(jiǎn)介
用opengl做的3D教室漫游程序,用vc6.0,可執(zhí)行,有詳細(xì)的注釋,是計(jì)算機(jī)圖形學(xué)的課程設(shè)計(jì)

代碼片段和文件信息
//////////////////////////////////////////////////////////////////////
//
//?OpenGL?Texture?Class
//?by:?Matthew?Fairfax
//
//?GLTexture.cpp:?implementation?of?the?GLTexture?class.
//?This?class?loads?a?texture?file?and?prepares?it
//?to?be?used?in?OpenGL.?It?can?open?a?bitmap?or?a
//?targa?file.?The?min?filter?is?set?to?mipmap?b/c
//?they?look?better?and?the?performance?cost?on
//?modern?video?cards?in?negligible.?I?leave?all?of
//?the?texture?management?to?the?application.?I?have
//?included?the?ability?to?load?the?texture?from?a
//?Visual?Studio?resource.?The?bitmap‘s?id?must?be
//?be?surrounded?by?quotation?marks?(i.e.?“Texture.bmp“).
//?The?targa?files?must?be?in?a?resource?type?of?“TGA“
//?(including?the?quotes).?The?targa‘s?id?must?be
//?surrounded?by?quotation?marks?(i.e.?“Texture.tga“).
//
//?Usage:
//?GLTexture?tex;
//?GLTexture?tex1;
//?GLTexture?tex3;
//
//?tex.Load(“texture.bmp“);?//?Loads?a?bitmap
//?tex.Use(); //?Binds?the?bitmap?for?use
//?
//?tex1.LoadFromResource(“texture.tga“);?//?Loads?a?targa
//?tex1.Use(); ?//?Binds?the?targa?for?use
//
//?//?You?can?also?build?a?texture?with?a?single?color?and?use?it
//?tex3.BuildColorTexture(255?0?0); //?Builds?a?solid?red?texture
//?tex3.Use(); ?//?Binds?the?targa?for?use
//
//////////////////////////////////////////////////////////////////////
#include?“GLTexture.h“
#include?
#include?
#include?
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
GLTexture::GLTexture()
{
}
GLTexture::~GLTexture()
{
}
void?GLTexture::Load(char?*name)
{
//?make?the?texture?name?all?lower?case
texturename?=?strlwr(strdup(name));
//?strip?“‘s
if?(strstr(texturename?“\““))
texturename?=?strtok(texturename?“\““);
//?check?the?file?extension?to?see?what?type?of?texture
if(strstr(texturename?“.bmp“))
LoadBMP(texturename);
if(strstr(texturename?“.tga“))
LoadTGA(texturename);
}
void?GLTexture::LoadFromResource(char?*name)
{
//?make?the?texture?name?all?lower?case
texturename?=?strlwr(strdup(name));
//?check?the?file?extension?to?see?what?type?of?texture
if(strstr(texturename?“.bmp“))
LoadBMPResource(name);
if(strstr(texturename?“.tga“))
LoadTGAResource(name);
}
void?GLTexture::Use()
{
glEnable(GL_TEXTURE_2D); //?Enable?texture?mapping
glBindTexture(GL_TEXTURE_2D?texture[0]); //?Bind?the?texture?as?the?current?one
}
void?GLTexture::LoadBMP(char?*name)
{
//?Create?a?place?to?store?the?texture
AUX_RGBImageRec?*TextureImage[1];
//?Set?the?pointer?to?NULL
memset(TextureImage0sizeof(void?*)*1);
//?Load?the?bitmap?and?assign?our?pointer?to?it
TextureImage[0]?=?auxDIBImageLoad(name);
//?Just?in?case?we?want?to?use?the?width?and?height?later
width?=?TextureImage[0]->sizeX;
height?=?TextureImage
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????98358??2007-12-09?14:41??Roaming?System(可執(zhí)行部分)\Data\backwall.bmp
?????文件?????393272??2007-12-05?19:31??Roaming?System(可執(zhí)行部分)\Data\blackboard.bmp
?????文件??????49206??2007-12-09?14:41??Roaming?System(可執(zhí)行部分)\Data\ceiling.bmp
?????文件??????49206??2007-12-03?21:50??Roaming?System(可執(zhí)行部分)\Data\floor.bmp
?????文件?????786486??2007-12-09?14:40??Roaming?System(可執(zhí)行部分)\Data\left.bmp
?????文件???????1301??2007-12-05?23:26??Roaming?System(可執(zhí)行部分)\Data\platform.3DS
?????文件??????33558??2007-12-09?13:43??Roaming?System(可執(zhí)行部分)\Data\platform.bmp
?????文件?????133445??2007-12-07?18:51??Roaming?System(可執(zhí)行部分)\Data\pole.3DS
?????文件?????383096??2007-12-07?13:10??Roaming?System(可執(zhí)行部分)\Data\pole.bmp
?????文件?????786486??2007-12-09?14:40??Roaming?System(可執(zhí)行部分)\Data\right.bmp
?????文件???????8596??2007-12-09?13:03??Roaming?System(可執(zhí)行部分)\Data\sdesk.jpg
?????文件?????106851??2007-12-09?22:35??Roaming?System(可執(zhí)行部分)\Data\sdesk1.3DS
?????文件?????223574??2007-12-09?22:33??Roaming?System(可執(zhí)行部分)\Data\sdesk2.3DS
?????文件?????133261??2007-12-07?11:21??Roaming?System(可執(zhí)行部分)\Data\soundbox.3DS
?????文件??????33558??2007-12-09?13:42??Roaming?System(可執(zhí)行部分)\Data\soundbox.bmp
?????文件???????8495??2007-12-05?22:29??Roaming?System(可執(zhí)行部分)\Data\tdesk.3DS
?????文件??????33558??2007-12-09?13:43??Roaming?System(可執(zhí)行部分)\Data\tdesk.bmp
????..A.SH.????137216??2007-12-09?22:59??Roaming?System(可執(zhí)行部分)\Data\Thumbs.db
?????文件?????294987??2007-12-10?21:33??Roaming?System(可執(zhí)行部分)\RoamingSystem.exe
?????文件????????229??2007-12-10?21:33??Roaming?System(可執(zhí)行部分)\使用說明.txt
?????文件????????127??2007-12-10?00:12??設(shè)計(jì)人員.txt
?????文件??????98358??2007-12-09?14:41??Roaming?System(工程部分)\Data\backwall.bmp
?????文件?????393272??2007-12-05?19:31??Roaming?System(工程部分)\Data\blackboard.bmp
?????文件??????49206??2007-12-09?14:41??Roaming?System(工程部分)\Data\ceiling.bmp
?????文件??????49206??2007-12-03?21:50??Roaming?System(工程部分)\Data\floor.bmp
?????文件?????786486??2007-12-09?14:40??Roaming?System(工程部分)\Data\left.bmp
?????文件???????1301??2007-12-05?23:26??Roaming?System(工程部分)\Data\platform.3DS
?????文件??????33558??2007-12-09?13:43??Roaming?System(工程部分)\Data\platform.bmp
?????文件?????133445??2007-12-07?18:51??Roaming?System(工程部分)\Data\pole.3DS
?????文件?????383096??2007-12-07?13:10??Roaming?System(工程部分)\Data\pole.bmp
............此處省略29個(gè)文件信息
評(píng)論
共有 條評(píng)論