glError 0x0501 when loading a large texture with OpenGL ES on the iPhone4

大憨熊 提交于 2019-12-06 15:35:24

Well, you try to create a texture bigger than GL_MAX_TEXTURE_SIZE, so it will fail. There is no way around that.

Btw, you can import texture at 4096x4096 and turn mip maps on, this would automatically use smaller resolution texture on older devices.

No, you can not. That is not what mipmaps are for. They are used when sampling the texture to avoid artifacts due to sparse sampling when the texture is shown smaller. You are still trying to create a 4096x4096 texure, which simply will not work on that device.

To solve this, you should either limit the texture size to the minimum supported size of all of the target devices you which to support, or dynamically query the GL_MAX_TEXTURE_SIZE limit and downscale the data before you try it to the GL, or provide different resolutions to choose from.

If you absolutely need that many pixels, you could also use some texture tiling approach and split it in multiple tiles - but that will probably require some major changes on your rendering code, and it might also lead to performance issues.

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