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

      



  • 相关阅读:
    希腊字母写法
    The ASP.NET MVC request processing line
    lambda aggregation
    UVA 10763 Foreign Exchange
    UVA 10624 Super Number
    UVA 10041 Vito's Family
    UVA 10340 All in All
    UVA 10026 Shoemaker's Problem
    HDU 3683 Gomoku
    UVA 11210 Chinese Mahjong
  • 原文地址:https://www.cnblogs.com/ezhong/p/2171456.html
Copyright © 2011-2022 走看看