2014/08/20

Texture from UIImage flips vertically

Make texture for OpenGL from UIImage / iPhone App Development Memo
↑I posted the way to make a texture image from a UIImage object in OpenGL. Later I found there may be in trouble with this way.

When I tried to use the Default.png image as texture in OpenGL, the texture sometimes flipped vertically.
I was able to recognize this problem because the Default.png image was not upper and lower symmetry. When I wrote the previous post, the image was upper and lower symmetry and I did not see any problem.
{
    UIImage *textureImage = [UIImage imageNamed:@“image.png”];
}
↑I usually load an image file like this, and I used this image as a texture in OpenGL.
I knew the image loaded with this imageNamed: method is cached in the system.
I remember I had to flip an image vertically when I use a UIImage object as a texture without GLKit.
Then,,, the cached image is flipped vertically??? I cannot believe it, but I tried to use imageWithContentsOfFile: method to load an image file, as the reference says.
Then, the trouble had disappeared!

By the way the method needs to write ”@2x” for the path.
Develop | Comments(0) | Trackback(0)
Comment

管理者のみに表示