iOS中两个纹理的非幂 [英] Non power of two textures in iOS
问题描述
在我的 iOS 应用程序(针对 iPad)中,我想使用两个非幂 (NPT) 纹理.我的 GL_VERSION 查询返回OpenGL ES 2.0 APPLE".根据规范,它应该支持 NPT 纹理,但一个简单的测试表明我需要将纹理调整为 2^N 才能显示出来.
In my iOS app (targeted for iPad), I'd like to use non power of two (NPT) textures. My GL_VERSION query returns "OpenGL ES 2.0 APPLE". According to the spec, it should support NPT textures, but a simple test shows that I need to resize the texture to 2^N before it shows up.
Apple 不支持完整的 ES 2.0 规范吗?在哪里可以找到不支持的文档?
Does Apple not support the full ES 2.0 spec? Where can I find documentation on what is not supported?
我使用的是 Xcode 4.3.2 和 iOS 5.1.
I am using Xcode 4.3.2 and iOS 5.1.
仔细查看 ES 2.0.25 规范(第 3.8.2 节),可以发现 NPOT 工作需要满足一些条件.基本上,如果我使用下面的设置,我可以加载 NPOT 纹理:
A closer look at the ES 2.0.25 spec (section 3.8.2), reveals that there are a few conditions to be met for NPOT to work. Essentially if I use the settings below, I am able to load NPOT textures:
// use linear filetring
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// clamp to edge
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
我应该关闭它还是回答我自己的问题?
Should I close this or answer my own question?
推荐答案
正如我在编辑中提到的,我找到了解决方案.ES 2.0 上的 NPOT 要求您使用线性过滤并钳制到边缘.此外,没有 mipmap.
As mentioned in my edit, I found the solution. NPOT on ES 2.0 requires that you use linear filtering and clamp to edge. Also, no mipmaps.
这篇关于iOS中两个纹理的非幂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!