gpt4 book ai didi

iphone - 在 iPhone 上渲染为非二次方纹理

转载 作者:行者123 更新时间:2023-12-03 18:26:38 25 4
gpt4 key购买 nike

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

也许在 ES 1.1 上无法完成?

最佳答案

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

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.

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.

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 Programming):

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

在这些设备上,只要设置正确的纹理环绕,您就应该能够使用非二次方纹理:

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

不幸的是,this example application我使用 OpenGL ES 2.0 渲染为非二次方纹理,所以我不确定这在这种情况下会对您有帮助。

关于iphone - 在 iPhone 上渲染为非二次方纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4760174/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com