在iOS中无法使用两种纹理 [英] Non power of two textures in iOS

查看:102
本文介绍了在iOS中无法使用两种纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iOS应用程序(针对iPad)中,我想使用两种非NPT(NPT)纹理。我的GL_VERSION查询返回OpenGL ES 2.0 APPLE。根据规范,它应该支持NPT纹理,但是一个简单的测试表明我需要在纹理显示之前将纹理大小调整为2 ^ N.



Apple不会支持完整的ES 2.0规范?我在哪里可以找到不支持的文档?



我使用的是Xcode 4.3.2和iOS 5.1。



<编辑:



仔细研究ES 2.0.25规范(第3.8.2节),可以发现NPOT有几个条件需要工作。基本上如果我使用下面的设置,我可以加载NPOT纹理:

  //使用线性文件串
glTexParameteri (GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
//限制边缘
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);

我应该关闭这个还是回答我自己的问题?

解决方案

正如我在编辑中提到的,我找到了解决方案。 ES 2.0上的NPOT要求您使用线性过滤和钳位到边缘。此外,没有mipmap。


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.

Does Apple not support the full ES 2.0 spec? Where can I find documentation on what is not supported?

I am using Xcode 4.3.2 and iOS 5.1.

Edit:

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?

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆