Simulating planar reflection using two-pass rendering and texture mapping
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.
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2009-05-12 13:39 task1
目录 0 2009-03-13 15:04 task1Data
文件 196662 2009-01-30 10:38 task1Dataack.bmp
文件 49206 2009-02-01 19:52 task1Datafloor.bmp
文件 196662 2009-01-30 10:43 task1Datafront.bmp
文件 196662 2009-01-30 10:46 task1Dataleft.bmp
文件 196662 2009-01-30 10:44 task1Data
ight.bmp
文件 196662 1998-09-10 04:06 task1Data eapot.BMP
文件 44032 2009-02-16 16:55 task1DataThumbs.db
目录 0 2009-04-07 16:45 task1Debug
文件 8658 2009-04-07 16:45 task1DebugBuildLog.htm
文件 66 2009-04-07 16:45 task1Debugmt.dep
文件 556032 2009-04-07 16:45 task1DebugPond.exe
文件 406 2009-04-07 15:47 task1DebugPond.exe.embed.manifest
文件 472 2009-04-07 15:47 task1DebugPond.exe.embed.manifest.res
文件 381 2009-04-07 16:45 task1DebugPond.exe.intermediate.manifest
文件 1497540 2009-04-07 16:45 task1DebugPond.ilk
文件 80245 2009-04-07 16:45 task1DebugPond.obj
文件 2616320 2009-04-07 16:45 task1DebugPond.pdb
文件 347136 2009-04-07 16:45 task1Debugvc90.idb
文件 110592 2009-04-07 16:45 task1Debugvc90.pdb
文件 12024 1998-04-24 00:00 task1GLAUX.H
文件 1312394 1998-05-13 00:00 task1GLAUX.LIB
文件 12648 1998-05-13 00:00 task1GLU32.LIB
文件 21440 2003-11-07 18:57 task1GLUT.H
文件 18316 2009-04-07 16:45 task1Pond.cpp
文件 533 2009-01-29 11:12 task1Pond.dsw
文件 555008 2009-02-19 10:31 task1Pond.exe
文件 14552064 2009-04-09 15:49 task1Pond.ncb
文件 878 2009-02-16 16:15 task1Pond.sln
文件 9728 2009-04-09 15:49 task1Pond.suo
............此处省略5个文件信息
#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 task1Data
文件 196662 2009-01-30 10:38 task1Dataack.bmp
文件 49206 2009-02-01 19:52 task1Datafloor.bmp
文件 196662 2009-01-30 10:43 task1Datafront.bmp
文件 196662 2009-01-30 10:46 task1Dataleft.bmp
文件 196662 2009-01-30 10:44 task1Data
ight.bmp
文件 196662 1998-09-10 04:06 task1Data eapot.BMP
文件 44032 2009-02-16 16:55 task1DataThumbs.db
目录 0 2009-04-07 16:45 task1Debug
文件 8658 2009-04-07 16:45 task1DebugBuildLog.htm
文件 66 2009-04-07 16:45 task1Debugmt.dep
文件 556032 2009-04-07 16:45 task1DebugPond.exe
文件 406 2009-04-07 15:47 task1DebugPond.exe.em
文件 472 2009-04-07 15:47 task1DebugPond.exe.em
文件 381 2009-04-07 16:45 task1DebugPond.exe.intermediate.manifest
文件 1497540 2009-04-07 16:45 task1DebugPond.ilk
文件 80245 2009-04-07 16:45 task1DebugPond.obj
文件 2616320 2009-04-07 16:45 task1DebugPond.pdb
文件 347136 2009-04-07 16:45 task1Debugvc90.idb
文件 110592 2009-04-07 16:45 task1Debugvc90.pdb
文件 12024 1998-04-24 00:00 task1GLAUX.H
文件 1312394 1998-05-13 00:00 task1GLAUX.LIB
文件 12648 1998-05-13 00:00 task1GLU32.LIB
文件 21440 2003-11-07 18:57 task1GLUT.H
文件 18316 2009-04-07 16:45 task1Pond.cpp
文件 533 2009-01-29 11:12 task1Pond.dsw
文件 555008 2009-02-19 10:31 task1Pond.exe
文件 14552064 2009-04-09 15:49 task1Pond.ncb
文件 878 2009-02-16 16:15 task1Pond.sln
文件 9728 2009-04-09 15:49 task1Pond.suo
............此处省略5个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)