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

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

问题描述

是否可以在 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扩展除了一个导出的实现扩展字符串将允许传递二维纹理的应用程序可能是也可能不是二的幂.

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 也不是 wrap 模式支持 CLAMP_TO_EDGE 以外的结合 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 上渲染为非二次幂纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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