bool COpenGLES::CreatePNGTexture(GLuint texID, const CString filename) { printf ( "png图片路径=%s\n" ,filename); CxImage * image = new CxImage(); image->Destroy(); unsigned char *pImage_RGBA = NULL; if (!(image->Load(filename,CXIMAGE_FORMAT_PNG))) { printf ( "加载图片失败\n" ); return false ; } if (!image->IsValid()) { printf ( "图片不可用\n" ); return false ; } int sizeX,sizeY; sizeX = image->GetWidth(); sizeY = image->GetHeight(); if (!image->AlphaIsValid()) { printf ( "alpha层错误\n" ); return false ; } long imageSize_RGBA = sizeX * sizeY * 4; //pImage_RGBA = new unsigned char[imageSize_RGBA]; image->Encode2RGBA(pImage_RGBA,imageSize_RGBA); glBindTexture(GL_TEXTURE_2D, texID); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sizeX, sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, pImage_RGBA); image->FreeMemory( pImage_RGBA); image->Destroy(); delete image; } |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ezhong的博客签名-------------------------------------
以上内容来自ezhong的博客园,作者:ezhong
ezhong的博客园: http://www.cnblogs.com/ezhong
感谢您的阅读。感谢您的分享。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步