资源描述:
《实验04_纹理映射》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、计算机图形学实验报告04北方工业大学计算机图形学课程实验报告题目:实验04_纹理映射学院:计算机学院专业:数字媒体技术指导教师:蔡兴泉学生班级:数媒13-2学生学号:13101090212学生姓名:常乐教师评定:1计算机图形学实验报告03学号:13101090212班级:数媒13-2姓名:常乐实验报告4纹理映射一.实验目的1.熟悉OpenGL图形库;2.掌握纹理映射实现方法。二.实验环境1.软件环境:操作系统:WinXp应用软件:VC6.0,OpenGL2.硬件环境(查看自己的机子)CPU:IntelPIV2.80GHz内存RAM:1GB显卡:
2、NVIDIAGeForce7650,256M显存三.实验内容1实现简单纹理映射。三维空间中画一个三角形,贴纹理。纹理图自己从网上下载给出源程序及效果截图。voidRenderScene(void){GLTVector3vNormal;GLTVector3vCorners[5]={{0.0f,.80f,0.0f},//Top0{-0.5f,0.0f,-.50f},//Backleft1{0.5f,0.0f,-0.50f},//Backright2{0.5f,0.0f,0.5f},//Frontright3{-0.5f,0.0f,0.5f}};//
3、Frontleft4//ClearthewindowwithcurrentclearingcolorglClear(GL_COLOR_BUFFER_BIT
4、GL_DEPTH_BUFFER_BIT);//SavethematrixstateanddotherotationsglPushMatrix();//MoveobjectbackanddoinplacerotationglTranslatef(0.0f,-0.25f,-4.0f);glRotatef(xRot,1.0f,0.0f,0.0f);glRotatef(yRot,0.0f,1.0f,
5、0.0f);//DrawthePyramidglColor3f(1.0f,1.0f,1.0f);glBegin(GL_TRIANGLES);10计算机图形学实验报告03//Bottomsection-twotrianglesglNormal3f(0.0f,-1.0f,0.0f);glTexCoord2f(1.0f,1.0f);glVertex3fv(vCorners[2]);glTexCoord2f(0.0f,0.0f);glVertex3fv(vCorners[4]);glTexCoord2f(0.0f,1.0f);glVertex3fv(v
6、Corners[1]);glTexCoord2f(1.0f,1.0f);glVertex3fv(vCorners[2]);glTexCoord2f(1.0f,0.0f);glVertex3fv(vCorners[3]);glTexCoord2f(0.0f,0.0f);glVertex3fv(vCorners[4]);//FrontFacegltGetNormalVector(vCorners[0],vCorners[4],vCorners[3],vNormal);glNormal3fv(vNormal);glTexCoord2f(0.5f,1.
7、0f);glVertex3fv(vCorners[0]);glTexCoord2f(0.0f,0.0f);glVertex3fv(vCorners[4]);glTexCoord2f(1.0f,0.0f);glVertex3fv(vCorners[3]);//LeftFacegltGetNormalVector(vCorners[0],vCorners[1],vCorners[4],vNormal);glNormal3fv(vNormal);glTexCoord2f(0.5f,1.0f);glVertex3fv(vCorners[0]);glTe
8、xCoord2f(0.0f,0.0f);glVertex3fv(vCorners[1]);glTexCoord2f(1.0f,0.0f);glVertex3fv(vCorners[4]);//BackFacegltGetNormalVector(vCorners[0],vCorners[2],vCorners[1],vNormal);glNormal3fv(vNormal);10计算机图形学实验报告03glTexCoord2f(0.5f,1.0f);glVertex3fv(vCorners[0]);glTexCoord2f(0.0f,0.0f)
9、;glVertex3fv(vCorners[2]);glTexCoord2f(1.0f,0.0f);glVertex3fv(vCorners[1]);