-
大小: 6.23MB文件类型: .zip金币: 2下载: 0 次发布日期: 2023-11-08
- 语言: 其他
- 标签: opengl reflection texture
资源简介
Simulating planar reflection using two-pass rendering and texture mapping
1. There ‘s a table with flat rectangular semi-reflective table-top in the 3D scene
2. On/Around the table are some 3D objects. All of these objects are texture-mapped (mipmapping).
3. There is a point light and a single directional light in the scene.
4. There is one rotating triangle floating in the air, casting a shadow on the table, walls and other objects.
5. The program allows the user to move the viewpoint and view direction.

代码片段和文件信息
#include
#include
#include
#include
#include
#include “glaux.h“
#define CheckedMalloc(mem_size) _CheckedMalloc( (mem_size) __FILE__ __LINE__ )
inline void *_CheckedMalloc( size_t size const char *srcfile int lineNum )
// same as malloc() but checks for out-of-memory.
{
void *p = malloc( size );
//if ( p == NULL ) ShowFatalError( srcfile lineNum “Cannot allocate memory.“ );
return p;
}
GLfloat angle =0;
GLfloat m_xAngle m_yAngle m_zAngle;
GLfloat m_xPos m_yPos m_zPos;
GLfloat height=3;
static GLfloat LightAmb[] = {0.7f 0.7f 0.7f 1.0f}; // Ambient Light
static GLfloat LightDif[] = {1.0f 1.0f 1.0f 1.0f}; // Diffuse Light
static GLfloat LightPos[] = {4.0f 4.0f 6.0f 1.0f}; // Light Position
static const char outputTestFilename[]=“test.out“;
GLuint texture[6];
AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle
if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}
File=fopen(Filename“r“); // Check To See If The File Exists
if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}
return NULL; // If Load Failed Return NULL
}
void loadtextures ()
{
int Status=FALSE; // Status Indicator
int loop;
AUX_RGBImageRec *TextureImage[6]; // Create Storage Space For The Textures
memset(TextureImage0sizeof(void *)*3); // Set The Pointer To NULL
if ((TextureImage[0]=LoadBMP(“Data/front.bmp“)) &&// Load The Floor Texture
(TextureImage[1]=LoadBMP(“Data/left.bmp“)) && // Load the Light Texture
(TextureImage[2]=LoadBMP(“Data/back.bmp“)) &&
(TextureImage[3]=LoadBMP(“Data/floor.bmp“))&&
(TextureImage[4]=LoadBMP(“Data/right.bmp“))&&
(TextureImage[5]=LoadBMP(“Data/teapot.bmp“))) // Load the Wall Texture
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(6 &texture[0]); // Create The Texture
for (loop=0; loop<6; loop++) // Loop Through 5 Textures
{
glBindTexture(GL_TEXTURE_2D texture[loop]);
glTexImage2D(GL_TEXTURE_2D 0 3 TextureImage[loop]->sizeX TextureImage[loop]->sizeY 0 GL_RGB GL_UNSIGNED_BYTE TextureImage[loop]->data);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
gluBuild2DMipmaps( GL_TEXTURE_2D 3 TextureImage[loop]->sizeX TextureImage[loop]->sizeY GL_RGB GL_UNSIGNED_BYTETextureImage[loop]->data );
}
for (loop=0; loop<6; loop++) // Loop Through 5 Textures
{
if (TextureImage[loop]) // If Texture Exists
{
if (TextureImage[loop]->data) // If Texture Image Exists
{
free(TextureImage[loop]->data); // Free The Texture Image Memory
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2009-05-12 13:39 task1\
目录 0 2009-03-13 15:04 task1\Data\
文件 196662 2009-01-30 10:38 task1\Data\back.bmp
文件 49206 2009-02-01 19:52 task1\Data\floor.bmp
文件 196662 2009-01-30 10:43 task1\Data\front.bmp
文件 196662 2009-01-30 10:46 task1\Data\left.bmp
文件 196662 2009-01-30 10:44 task1\Data\right.bmp
文件 196662 1998-09-10 04:06 task1\Data\teapot.BMP
文件 44032 2009-02-16 16:55 task1\Data\Thumbs.db
目录 0 2009-04-07 16:45 task1\Debug\
文件 8658 2009-04-07 16:45 task1\Debug\BuildLog.htm
文件 66 2009-04-07 16:45 task1\Debug\mt.dep
文件 556032 2009-04-07 16:45 task1\Debug\Pond.exe
文件 406 2009-04-07 15:47 task1\Debug\Pond.exe.em
文件 472 2009-04-07 15:47 task1\Debug\Pond.exe.em
文件 381 2009-04-07 16:45 task1\Debug\Pond.exe.intermediate.manifest
文件 1497540 2009-04-07 16:45 task1\Debug\Pond.ilk
文件 80245 2009-04-07 16:45 task1\Debug\Pond.obj
文件 2616320 2009-04-07 16:45 task1\Debug\Pond.pdb
文件 347136 2009-04-07 16:45 task1\Debug\vc90.idb
文件 110592 2009-04-07 16:45 task1\Debug\vc90.pdb
文件 12024 1998-04-24 00:00 task1\GLAUX.H
文件 1312394 1998-05-13 00:00 task1\GLAUX.LIB
文件 12648 1998-05-13 00:00 task1\GLU32.LIB
文件 21440 2003-11-07 18:57 task1\GLUT.H
文件 18316 2009-04-07 16:45 task1\Pond.cpp
文件 533 2009-01-29 11:12 task1\Pond.dsw
文件 555008 2009-02-19 10:31 task1\Pond.exe
文件 14552064 2009-04-09 15:49 task1\Pond.ncb
文件 878 2009-02-16 16:15 task1\Pond.sln
文件 9728 2009-04-09 15:49 task1\Pond.suo
............此处省略5个文件信息
相关资源
- 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文件
- Influence of shear banding on the formation of
- Experiment investigation of deep-drawing sheet
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
评论
共有 条评论