欢迎来到天天文库
浏览记录
ID:31532906
大小:1.42 MB
页数:17页
时间:2019-01-13
《大鱼吃小鱼详细设计》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、大鱼吃小鱼详细设计设计者:叶思雨开始时间:2011-11-22版本进度时间主题备注0.0第一步–第三步2011-11-22贴背景图0.1第四步2011-11-23实现大鱼吃小鱼功能0.2第五步2011-11-25文字系统0.5第六步2011-11-26声音系统1.0第七步优化第17页第一步准备工作:创建工程,将教程的源代码复制进去,并把两个动态链接库放到连接下面去。在工程目录下创建文件夹名为“Data”,其中有bg.bmp背景图和fish.bmp小鱼儿图。第二步贴图背景图2.1定义全局变量constintn=2;//图片的张数GLuintt
2、exture[n];2.2复制贴图代码//贴图之前的准备说明该函数是用来选择一个位图AUX_RGBImageRec*LoadBMP(char*Filename)//LoadsABitmapImage{FILE*File=NULL;//FileHandleif(!Filename){returnNULL;//IfNotReturnNULL}File=fopen(Filename,"r");//CheckToSeeIfTheFileExistsif(File)//DoesTheFileExist?{fclose(File);//CloseThe
3、HandlereturnauxDIBImageLoad(Filename);}returnNULL;//IfLoadFailedReturnNULL第17页}//选择好图片并按次序绑定intLoadGLTextures()//LoadBitmapsAndConvertToTextures{intStatus=FALSE;//StatusIndicatorinti;//图片变量AUX_RGBImageRec*TextureImage[n];memset(TextureImage,0,sizeof(void*)*n);//SetThePoint
4、erToNULL//在此处选择图片TextureImage[0]=LoadBMP("Data/bg.bmp");TextureImage[1]=LoadBMP("Data/fish.bmp");//此处添加图片for(i=0;i5、glBindTexture(GL_TEXTURE_2D,texture[i]);glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[i]->sizeX,TextureImage[i]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[i]->data);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG6、_FILTER,GL_LINEAR);}if(TextureImage[i])//IfTextureExists{if(TextureImage[i]->data)//IfTextureImageExists{free(TextureImage[i]->data);//FreeTheTextureImageMemory}第17页free(TextureImage[i]);//FreeTheImageStructure}}returnStatus;//ReturnTheStatus}2.3初始化中载入if(!LoadGLTextures())7、//载入贴图returnfalse;glEnable(GL_TEXTURE_2D);//启动贴图2.4写一个画背景图函数voidDrawbg(GLvoid){glBindTexture(GL_TEXTURE_2D,texture[0]);//根据标识绑定哪个图片glBegin(GL_QUADS);//对应顶点贴背景图glTexCoord2f(1.0f,0.0f);glVertex3f(2.0f,-1.2f,-1.0f);glTexCoord2f(1.0f,1.0f);glVertex3f(2.0f,1.2f,-1.0f);glTexCoor8、d2f(0.0f,1.0f);glVertex3f(-2.0f,1.2f,-1.0f);glTexCoord2f(0.0f,0.0f);glVertex3f(-2.0f,-1.2
5、glBindTexture(GL_TEXTURE_2D,texture[i]);glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[i]->sizeX,TextureImage[i]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[i]->data);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG
6、_FILTER,GL_LINEAR);}if(TextureImage[i])//IfTextureExists{if(TextureImage[i]->data)//IfTextureImageExists{free(TextureImage[i]->data);//FreeTheTextureImageMemory}第17页free(TextureImage[i]);//FreeTheImageStructure}}returnStatus;//ReturnTheStatus}2.3初始化中载入if(!LoadGLTextures())
7、//载入贴图returnfalse;glEnable(GL_TEXTURE_2D);//启动贴图2.4写一个画背景图函数voidDrawbg(GLvoid){glBindTexture(GL_TEXTURE_2D,texture[0]);//根据标识绑定哪个图片glBegin(GL_QUADS);//对应顶点贴背景图glTexCoord2f(1.0f,0.0f);glVertex3f(2.0f,-1.2f,-1.0f);glTexCoord2f(1.0f,1.0f);glVertex3f(2.0f,1.2f,-1.0f);glTexCoor
8、d2f(0.0f,1.0f);glVertex3f(-2.0f,1.2f,-1.0f);glTexCoord2f(0.0f,0.0f);glVertex3f(-2.0f,-1.2
此文档下载收益归作者所有