Data.cpp
资源名称:XLT.rar [点击查看]
上传用户:yunyi28
上传日期:2021-04-25
资源大小:6978k
文件大小:2k
源码类别:
分形几何
开发平台:
Visual C++
- #include "Data.h"
- list<TreeType> treeType;
- list<Tree> trees;
- GLuint bmptexture[11];
- GLuint texture[1];
- AUX_RGBImageRec *LoadBMP(char *filename);
- int LoadGLTexture();
- void InitData()
- {
- glGenTextures(10, &bmptexture[0]);
- if( !BMP::LoadBMPTexture(&bmptexture[0],"../Texture/treebody.bmp") ||
- !BMP::LoadBMPTexture(&bmptexture[2],"../Texture/Image1.bmp") ||
- !BMP::MakeAlphaTextureBind("../Texture/Image1.bmp",&bmptexture[3])
- )
- {
- MessageBox(NULL,"Can't open bmp",NULL,NULL);
- return;
- }
- if(!LoadGLTexture())
- return ;
- }
- AUX_RGBImageRec *LoadBMP(char *filename)
- {
- FILE *f=NULL;
- if(!filename)
- {
- return NULL;
- }
- f = fopen(filename,"r");
- if(f)
- {
- fclose(f);
- // wchar_t *pwText;
- // int size=MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, -1);
- // pwText = new wchar_t[size];
- // MultiByteToWideChar(CP_ACP, 0, filename, -1, pwText, size);
- // delete []pwText;
- return auxDIBImageLoad(filename);
- }
- return NULL;
- }
- int LoadGLTexture()
- {
- int status=FALSE;
- AUX_RGBImageRec *TextureImage[1];
- memset(TextureImage,0,sizeof(void*)*1);
- if(TextureImage[0]=LoadBMP("../Texture/bmp1.bmp"))
- {
- status=TRUE;
- glGenTextures(1,&texture[0]);
- glBindTexture(GL_TEXTURE_2D,texture[0]);
- glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[0]->sizeX,TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[0]->data);
- // glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
- // glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
- }
- if(TextureImage[0])
- {
- if(TextureImage[0]->data)
- free(TextureImage[0]->data);
- free(TextureImage[0]);
- }
- return status;
- }