资源简介
Visual C++ / opengl 实现的阴影算法;

代码片段和文件信息
// a bouncing ball
// Ping-Che Chen
#define GLUT_DISABLE_ATEXIT_HACK
#include
#include
#include
#include
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
#ifndef WIN32
#include
typedef clock_t my_clock_t;
#else
#define WIN32_LEAN_AND_MEAN
#include
typedef LONGLONG my_clock_t;
#endif
const char* title = “ball“;
// number bitmaps
const GLubyte number[12][8] = {
{ 0x00 0x7C 0xE6 0xF6 0xDE 0xCE 0xC6 0x7C } // 0
{ 0x00 0xFC 0x30 0x30 0x30 0x30 0x70 0x30 } // 1
{ 0x00 0xFC 0xCC 0x60 0x38 0x0C 0xCC 0x78 } // 2
{ 0x00 0x78 0xCC 0x0C 0x38 0x0C 0xCC 0x78 } // 3
{ 0x00 0x1E 0x0C 0xFE 0xCC 0x6C 0x3C 0x1C } // 4
{ 0x00 0x78 0xCC 0x0C 0x0C 0xF8 0xC0 0xFC } // 5
{ 0x00 0x78 0xCC 0xCC 0xF8 0xC0 0x60 0x38 } // 6
{ 0x00 0x30 0x30 0x30 0x18 0x0C 0xCC 0xFC } // 7
{ 0x00 0x78 0xCC 0xCC 0x78 0xCC 0xCC 0x78 } // 8
{ 0x00 0x70 0x18 0x0C 0x7C 0xCC 0xCC 0x78 } // 9
{ 0x00 0x30 0x30 0x00 0x00 0x00 0x00 0x00 } // .
{ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 } // others
};
// display lists
GLuint box;
GLuint sphere;
GLuint fonts;
GLuint wall;
// viewer position
const GLdouble eye[3] = { 0.5 1.5f 5 };
const GLdouble center[3] = { 0 1.5f 0 };
// light
GLfloat light_pos[4] = { 2 3 4 0 };
// color
const GLfloat color_box[3] = { 0.7f 0.4f 0.1f };
const GLfloat color_sphere[3] = { 0.3f 0.1f 0.9f };
const GLfloat color_shadow[3] = { 0.3f 0.3f 0.3f };
const GLfloat color_wall[3] = { 0.6f 0.3f 0.4f };
// ground parameter (Ax + By + Cz + D = 0)
const GLfloat ground_parameter[4] = { 0 1 0 0 };
const GLfloat wall_parameter1[4] = { 0 0 1 4 };
const GLfloat wall_parameter2[4] = { 1 0 0 4 };
// clip planes
const GLdouble plane0[4] = { 0 0 1 4 };
const GLdouble plane1[4] = { 1 0 0 4 };
const GLdouble plane2[4] = { 0 1 0 0 };
// shadow matrix
GLfloat shadow_matrix[4][4];
GLfloat shadow_matrix1[4][4];
GLfloat shadow_matrix2[4][4];
// ball position
GLfloat ball_t = 0;
my_clock_t last_time timer_frequency last_sec_time;
int frame_no = 0;
bool odd_frame = false z_trick = false;
float fps = 0;
my_clock_t get_system_time()
{
#ifdef WIN32
LARGE_INTEGER r;
QueryPerformanceCounter(&r);
return r.QuadPart;
#else
struct timeval t;
gettimeofday(&t NULL);
return t.tv_sec * 1000 + t.tv_usec / 1000;
#endif
}
void set_up_system_time()
{
#ifdef WIN32
LARGE_INTEGER r;
QueryPerformanceFrequency(&r);
if(r.QuadPart == 0) {
throw “Timer is not available“;
}
timer_frequency = r.QuadPart;
#else
timer_frequency = 1000;
#endif
last_sec_time = last_time = get_system_time();
}
void generate_box(GLuint p GLfloat width GLfloat height GLfloat depth)
{
GLfloat x y z;
x = width / 2;
y = -height;
z = depth / 2;
glNewList(p GL_COMPILE);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11034 2013-10-14 18:41 shadow\ball_shadow.cpp
文件 4180 1999-08-18 03:17 shadow\ball_shadow.dsp
文件 545 1999-06-28 02:32 shadow\ball_shadow.dsw
文件 40960 2000-06-08 03:01 shadow\ball_shadow.exe
文件 50176 2013-12-18 17:05 shadow\ball_shadow.ncb
文件 78848 2013-12-18 17:05 shadow\ball_shadow.opt
文件 1206 2013-12-18 17:03 shadow\ball_shadow.plg
文件 169984 1998-08-18 16:25 shadow\glut32.dll
目录 0 2013-12-18 17:03 shadow\Debug
目录 0 2013-12-18 17:05 shadow
----------- --------- ---------- ----- ----
356933 10
- 上一篇:网关模板 C/C++程序编写
- 下一篇:基于QT的网络聊天室和服务器
相关资源
- 安卓c语言开发SDL2+opengles
- 交互式计算机图形学 第六版 OpenGL源代
- VC++基于OpenGL模拟的一个3维空间模型
- opengl绘制汽车.cpp
- opengl实现水流效果sph
- opengl源代码,全是精华!
- OpenGL迷宫山东大学图形学实验三
- opengl的立方体消隐算法
- vc++ opengl代码爆炸
- 我见过最漂亮的CS仿真程序openGL和C+
- 广东某工业大学的openGL课程设计
- 使用OpenGL实现多个小球在密闭空间内
- 利用openGL和C++实现光线跟踪绘图的完
- OpenGl C++太阳系小行星运行系统 可切换
- vc++和OpenGL实现三维地形实时动态显示
- C++实现利用OpenGL实现三维绘图
- 太阳、地球、月亮之间的运动图Open
- MFC 单文档 实现opengl 三维旋转 缩放
- OPENGL的烟花程序(代码)
- MFC+OpenGL三维建模与动画显示
- 基于opengl粒子系统实现喷泉的模拟
- 一个基于openGL的太阳系模型,太阳地
- vc6.0+opengl纯色五角星填充
- vc6.0+opengl动态绘制五角星
- NeHe_OpenGL教程完整版 里面有地址可以
- OpenGL简单——实现立方体贴上不同纹
- MFC实现dem的读取与现实
- VC++ OpenGL三维地形漫游
- OpenGL实现三维地形实时动态显示
- VC++中Opengl实现建筑物虚拟漫游
评论
共有 条评论