iphone opengl es 2.0 non power of two

醉酒当歌 提交于 2019-12-23 04:22:12

问题


I thought the image file size doesn't have to be power of two in 2.0 but when I tried, it just showed black screen. But it works fine with power of two images. Can anyone give me some hint what I am missing or I should do to use NPOT images? Thank you


回答1:


OpenGL ES for iOS requires Power-of-Two images, unfortunately, as it is a rather strict implementation (case in point, look at all of the stuff that is not available in OpenGL ES).

If your image is non-power-of-two there are a few solutions.

First, the most obvious, you must add some padding to the image to make it so. This can be done either in an image editor, or programatically when you load the texture data.

Second, if you have multiple textures, you can instead compile your images into one larger image using a texture packing tool. This is a more targeted approach depending on your intended use, and requires some more work if you are intending to use the texture for more than one 3D mesh or model as your UV/texture coordinates will be different from their originals.

Edit

Since not everyone reads the comments, I'll quote my comment to give it higher visibility. Under very specific circumstances, NPOT textures are valid, as is follows.

After a bit of digging, NPOT textures are technically enabled in the newer iOS hardware running 2.0 ES, but with extremely limited use. Specifically, you must use linear filtering with clamp-to-edge, and no mipmapping. This limits your use, and in most cases a power-of-two image would still be more efficient/have higher framerates.



来源:https://stackoverflow.com/questions/11620320/iphone-opengl-es-2-0-non-power-of-two

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!