zoukankan      html  css  js  c++  java
  • OpenGLES加载png纹理/WinCE6.0/Cximage库


    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;
    
    }
    

      



  • 相关阅读:
    容斥原理
    泰勒展开
    初等微积分
    粒子群优化(微粒群算法)
    生成函数
    FFT例题
    图论例题
    线段求交
    期望小小结
    [Violet]天使玩偶/SJY摆棋子
  • 原文地址:https://www.cnblogs.com/ezhong/p/2171456.html
Copyright © 2011-2022 走看看