-
大小: 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個文件信息
評論
共有 條評論