0

I'm using cpp/marmalade to make a game for ios, but sometimes textures render corrupted. Here is the source texture file:

http://files.moonmana.com/forums/source-rune.png

Example of a currupted texture:

enter image description here

I'm loading texture with this code:

VGTexture2D* VGTextureLoader::loadImage(std::string imagefile)
{


CIwImage img;
 img.LoadFromFile(imagefile.c_str());

 // Convert to an OpenGL ES native format
 CIwImage nativeImg;
 nativeImg.SetFormat(CIwImage::ABGR_8888);
 img.ConvertToImage(&nativeImg);

 // Generate texture object
 GLuint texture;
 glGenTextures(1, &texture);
 glBindTexture(GL_TEXTURE_2D, texture);

 // Upload
 uint32 width = img.GetWidth();
 uint32 height = img.GetHeight();
 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nativeImg.GetTexels());


 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_WRAP_S, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

 // Create and return texture
 VGTexture2D* tex = new VGTexture2D(texture, (float)width, (float)height);

 return tex;
}
4

1 回答 1

3

你的纹理没有被破坏,但通道似乎被翻转了。可能是因为您将图像转换为 ABGR_8888,然后将其上传为 GL_RGBA?

于 2012-04-22T03:36:52.447 回答