0

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

in His Steps
  • 3,075
  • 6
  • 30
  • 38

1 Answers1

2

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.

CrimsonDiego
  • 3,616
  • 1
  • 23
  • 26
  • But when I read iPhone 3D Programming written by Philip Rideout, he said 2.0 is not limited by power of two thing. – in His Steps Jul 23 '12 at 21:06
  • Unless I am grievously mistaken in both experience and research, that book is wrong. I have never seen otherwise, and just about every iOS OpenGL ES texturing tutorial mentions this fact. – CrimsonDiego Jul 23 '12 at 21:10
  • 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. – CrimsonDiego Jul 23 '12 at 21:18
  • @CrimsonDiego: You should edit your answer and add your new findings. I've used NPOT on some occasions when working with 2D graphics, and they can be useful to save memory for untilable textures. – Anton Jul 24 '12 at 20:42
  • I found a number of errors in that book, so him being wrong about the POT thing is entirely feasible – occulus Dec 21 '16 at 16:03