资源简介
opengl的一个CS三维场景,很逼真,适合opengl游戏开发和opengl初学者学习的一个很好地代码

代码片段和文件信息
#include “Defines.h“
#include “Quake3BSP.h“
#include “LoadTexture.h“
#include “Glext.h“
#include “Camera.h“
#include “Frustum.h“
#include “FPS.h“
//FIXME: ugly externs and globals and defines again :(
#define ENDL “\n“
#define LMAPSIZE (128*128*3)
int closestplane;
float RADIUS = 10.0f; //not sure what this should be defined as
#define EPSILON .03125
int LastPlaneCrossed;
extern Vector3 BoxMaxs;
extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
extern Camera cam;
extern Frustum frus;
extern FPS_t FPS;
std::ofstream trace(“Trace.txt“);
std::ofstream textures(“textures.txt“);
struct pixelf
{
pixelf(){}
pixelf(float rtfloat gtfloat bt):r(rt)g(gt)b(bt){}
float rgb;
};
struct pixelfa
{
pixelfa(){}
pixelfa(float rtfloat gtfloat btfloat at):r(rt)g(gt) b(bt) a(at){}
float rgba;
};
//To make Y up swap the Y and Z values and negate new Z
void BSP::MakeYUp(Vector3 * a)
{
float temp = a->z;
a->z = -a->y;
a->y = temp;
}
//for leaf bounding boxes
void BSP::MakeYUp(tVector3i *a)
{
float temp = a->z;
a->z = -a->y;
a->y = temp;
}
//byte [128][128][3]
//equals to rgb for 128 x 128 map
UINT BSP::GenLightmap(tBSPLightmap * lightmap)
{
UINT texture = 0;
glGenTextures(1 &texture);
//FIXME: look more into how these texture functions work possible optimizations anywhere?
//this function determines how the pixel data is stored in memory not significant unless you are
//reading the data from screen for a screenshot or something
// the second parameter is how many bytes between rows of pixel memory
glPixelStorei(GL_UNPACK_ALIGNMENT 1);
//creates/selects the texture
glBindTexture(GL_TEXTURE_2D texture);
pixelf pixel;
float max temp;
//touch every single pixel and manipulate its color while keeping things in range
byte *ImageData = &lightmap->imageBits[0][0][0];
for(int i = 0; i < LMAPSIZE; i+=3)
{
max = 1.0f;
temp = 0.0f;
pixel=pixelf(((float)ImageData[i]*3.1)/255.0f((float)ImageData[i+1]*3.1)/255.0f((float)ImageData[i+2]*3.1)/255.0f);
if(pixel.r > 1.0f)
if((1.0f/pixel.r) < max)
max = 1.0f/pixel.r;
if(pixel.g > 1.0f)
if((1.0f/pixel.g) < max)
max = 1.0f/pixel.g;
if(pixel.b > 1.0f)
if((1.0f/pixel.b) < max)
max = 1.0f/pixel.b;
max*=255;
pixel=pixelf(pixel.r*max pixel.g*max pixel.b*max);
ImageData[i] = (byte)pixel.r;
ImageData[i+1] = (byte)pixel.g;
ImageData[i+2] = (byte)pixel.b;
}
//mip maps generate arrays of the same texture information so that it uses lower resolution textures
//when you are far away and higher resolution textures when you are up close
//because our lightmaps are 128x128 that is static to this function
//second parameter is number of channels rgb (+a if 4 channels)
gluBuild2DMipmaps(GL_TEXTURE_2D 3 128 128 GL_RGB GL_UNSIGNED_BYTE lightmap->imageBits);
//sets up variou
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 639078 2003-07-21 21:51 OPenglCS三维场景\Demo\BSP.exe
文件 1922308 2002-08-07 22:41 OPenglCS三维场景\Demo\GameTutorialsBSP.bsp
文件 0 2013-12-12 16:58 OPenglCS三维场景\Demo\textureerror.txt
文件 714389 2001-01-11 21:08 OPenglCS三维场景\Demo\textures\frozendusk\frozendusk_bk.tga
文件 769520 2001-01-11 21:16 OPenglCS三维场景\Demo\textures\frozendusk\frozendusk_dn.tga
文件 616955 2001-01-11 21:02 OPenglCS三维场景\Demo\textures\frozendusk\frozendusk_ft.tga
文件 553935 2001-01-11 21:05 OPenglCS三维场景\Demo\textures\frozendusk\frozendusk_lf.tga
文件 629842 2001-01-11 21:25 OPenglCS三维场景\Demo\textures\frozendusk\frozendusk_rt.tga
文件 297903 2001-01-11 21:13 OPenglCS三维场景\Demo\textures\frozendusk\frozendusk_up.tga
文件 49196 2000-10-08 18:48 OPenglCS三维场景\Demo\textures\q3hh2\2r_plaster_floor01.tga
文件 49196 2000-10-08 18:48 OPenglCS三维场景\Demo\textures\q3hh2\2r_plaster_floor02.tga
文件 24620 2000-10-28 21:50 OPenglCS三维场景\Demo\textures\q3hh2\2_256_red_thin01.tga
文件 24620 2000-10-28 21:50 OPenglCS三维场景\Demo\textures\q3hh2\2_256_red_thin02.tga
文件 98348 2000-11-16 02:55 OPenglCS三维场景\Demo\textures\q3hh2\2_256_white_sup03.tga
文件 24620 2000-11-16 02:53 OPenglCS三维场景\Demo\textures\q3hh2\2_32_red_thin02.tga
文件 24620 2000-10-19 19:57 OPenglCS三维场景\Demo\textures\q3hh2\2_8_step03.tga
文件 6188 2000-10-19 19:57 OPenglCS三维场景\Demo\textures\q3hh2\2_8_step03b.tga
文件 196652 2000-10-26 00:49 OPenglCS三维场景\Demo\textures\q3hh2\2_circuit_overlay.tga
文件 49196 2000-10-28 21:17 OPenglCS三维场景\Demo\textures\q3hh2\2_conc01.tga
文件 98348 2000-11-16 02:37 OPenglCS三维场景\Demo\textures\q3hh2\2_conc02.tga
文件 98348 2000-11-16 02:37 OPenglCS三维场景\Demo\textures\q3hh2\2_conc03.tga
文件 196652 2000-10-08 18:43 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_celing01.tga
文件 196652 2000-11-16 02:34 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_floorpat01.tga
文件 196652 2000-11-16 02:33 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_floorpat02.tga
文件 49196 2000-11-16 02:38 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_l01.tga
文件 49196 2000-11-16 02:38 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_l04.tga
文件 49196 2000-11-16 02:38 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_l05.tga
文件 196652 2000-10-08 15:12 OPenglCS三维场景\Demo\textures\q3hh2\2_conc_wall01.tga
文件 65580 2000-10-18 16:49 OPenglCS三维场景\Demo\textures\q3hh2\2_c_128_trellis01b2.tga
文件 32812 2000-10-28 22:31 OPenglCS三维场景\Demo\textures\q3hh2\2_c_thinredtrim03.tga
............此处省略52个文件信息
- 上一篇:北京市王府井平面图
- 下一篇:《大学物理基础吴百诗编》课后题答案上下全
相关资源
- 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室内场景的绘制,包括碰撞检测
评论
共有 条评论