在iPhone上渲染到非2次幂纹理 [英] Rendering to non-power-of-two texture on iPhone

查看:521
本文介绍了在iPhone上渲染到非2次幂纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在iPhone(2G及更早版本)上使用OpenGL ES 1.1渲染纹理?如果我将纹理绑定为渲染缓冲区,则它必须是渲染缓冲区的大小,而不是POT大小。但OpenGL ES 1.1要求纹理为POT。

Is it possible to render to texture with OpenGL ES 1.1 on the iPhone (2G and older)? If I bind a texture as a render buffer, it has to be the size of the render buffer, which isn't POT-sized. But OpenGL ES 1.1 requires textures to be POT.

也许在ES 1.1上无法完成?

Maybe it can't be done on ES 1.1?

推荐答案

虽然OpenGL ES 1.1不支持非二次幂纹理,但较新的iOS设备型号的扩展名为 GL_APPLE_texture_2D_limited_npot ,其中说明:

While OpenGL ES 1.1 does not support non-power-of-two textures, newer iOS device models have the extension GL_APPLE_texture_2D_limited_npot, which states:


传统的OpenGL ES 1.X纹理
仅限于具有2次幂
(POT)尺寸的图像。
APPLE_texture_2D_limited_npot
扩展放宽了这些尺寸
对2D纹理的限制。如果支持,
地图和3D纹理的
限制仍然存在。

Conventional OpenGL ES 1.X texturing is limited to images with power-of-two (POT) dimensions. APPLE_texture_2D_limited_npot extension relaxes these size restrictions for 2D textures. The restrictions remain in place for cube map and 3D textures, if supported.

没有额外的过程或
枚举API由
扩展引入,但
实现导出
扩展字符串将允许
应用程序传递2D纹理
维度,可能是也可能不是
2的幂。

There is no additional procedural or enumerant API introduced by this extension except that an implementation which exports the extension string will allow an application to pass in 2D texture dimensions that may or may not be a power of two.

在没有OES_texture_npot的情况下,
解除了这些限制,
既不是mipmapping也不是包装模式$ b $除了CLAMP_TO_EDGE以外的b与NPOT 2D纹理一起支持

NPOT 2D纹理,包裹模式
不是CLAMP_TO_EDGE或
minfilter不是NEAREST或
LINEAR被认为是不完整的。如果
这样的纹理绑定到纹理
单位,就好像为该纹理单元禁用了纹理映射

In the absence of OES_texture_npot, which lifts these restrictions, neither mipmapping nor wrap modes other than CLAMP_TO_EDGE are supported in conjunction with NPOT 2D textures. A NPOT 2D texture with a wrap mode that is not CLAMP_TO_EDGE or a minfilter that is not NEAREST or LINEAR is considered incomplete. If such a texture is bound to a texture unit, it is as if texture mapping were disabled for that texture unit.

您可以使用以下代码来确定您的设备是否支持此扩展程序(来自Philip Rideout的优秀 iPhone 3D编程一书):

You can use the following code to determine if this extension is supported on your device (drawn from Philip Rideout's excellent iPhone 3D Programming book):

const char* extensions = (char*) glGetString(GL_EXTENSIONS); 
bool npot = strstr(extensions, "GL_APPLE_texture_2D_limited_npot") != 0;

在这些设备上,您应该能够使用非幂二纹理在设置正确的纹理包装时:

On these devices, you should then be able to use non-power-of-two textures as long as you set the proper texture wrapping:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

不幸的是,这个示例应用程序,我使用OpenGL ES 2.0渲染到非二次幂纹理,所以我不确定在这种情况下会对你有所帮助。

Unfortunately, this example application that I have which renders to a non-power-of-two texture uses OpenGL ES 2.0, so I'm not sure that will help you in this case.

这篇关于在iPhone上渲染到非2次幂纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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