资源简介
简单的3D教室漫游程序 Win32平台,OpenGL开发

代码片段和文件信息
//////////////////////////////////////////////////////////////////////
//
// 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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 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
文件 786486 2007-12-09 14:40 Roaming System(可执行部分)\Data\right.bmp
文件 8596 2007-12-09 13:03 Roaming System(可执行部分)\Data\sdesk.jpg
文件 106851 2007-12-09 22:35 Roaming System(可执行部分)\Data\sdesk1.3DS
文件 223574 2007-12-09 22:33 Roaming System(可执行部分)\Data\sdesk2.3DS
文件 133261 2007-12-07 11:21 Roaming System(可执行部分)\Data\soundbox.3DS
文件 33558 2007-12-09 13:42 Roaming System(可执行部分)\Data\soundbox.bmp
文件 8495 2007-12-05 22:29 Roaming System(可执行部分)\Data\tdesk.3DS
文件 33558 2007-12-09 13:43 Roaming System(可执行部分)\Data\tdesk.bmp
..A.SH. 137216 2007-12-09 22:59 Roaming System(可执行部分)\Data\Thumbs.db
文件 294987 2007-12-10 21:33 Roaming System(可执行部分)\RoamingSystem.exe
文件 229 2007-12-10 21:33 Roaming System(可执行部分)\使用说明.txt
文件 127 2007-12-10 00:12 设计人员.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
............此处省略28个文件信息
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
- OpenGL实现飘动效果
- opengl室内场景的绘制,包括碰撞检测
评论
共有 条评论