iphone opengl es 2.0非二的幂 [英] iphone opengl es 2.0 non power of two

查看:197
本文介绍了iphone opengl es 2.0非二的幂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为图像文件的大小不必是2.0中的2的幂 但是当我尝试时,它只是显示黑屏. 但是,使用两个图像的强大功能就可以正常工作. 谁能给我一些提示,或者我想使用NPOT图像该怎么做? 谢谢

I thought the image file size doesn't have to be power of two in 2.0 but when I tried, it just showed black screen. But it works fine with power of two images. Can anyone give me some hint what I am missing or I should do to use NPOT images? Thank you

推荐答案

iOS的OpenGL ES需要2次幂图像,因为这是一个相当严格的实现(例如,请查看所有在OpenGL ES中不可用.)

OpenGL ES for iOS requires Power-of-Two images, unfortunately, as it is a rather strict implementation (case in point, look at all of the stuff that is not available in OpenGL ES).

如果您的图像不是二次幂,则有一些解决方案.

If your image is non-power-of-two there are a few solutions.

首先,最明显的是,必须在图像上添加一些填充以使其变得如此.这可以在图像编辑器中完成,也可以在加载纹理数据时以编程方式完成.

First, the most obvious, you must add some padding to the image to make it so. This can be done either in an image editor, or programatically when you load the texture data.

第二,如果您具有多个纹理,则可以使用纹理打包工具将图像编译为一个较大的图像.这是一种针对性更强的方法,具体取决于您的预期用途,并且如果您打算将纹理用于多个3D网格或模型,则需要做更多的工作,因为您的UV/纹理坐标将不同于其原始坐标.

Second, if you have multiple textures, you can instead compile your images into one larger image using a texture packing tool. This is a more targeted approach depending on your intended use, and requires some more work if you are intending to use the texture for more than one 3D mesh or model as your UV/texture coordinates will be different from their originals.

编辑

Edit

由于并非所有人都阅读评论,因此我将引用我的评论以使其具有更高的可见性.在非常特定的情况下,NPOT纹理是有效的,如下所示.

Since not everyone reads the comments, I'll quote my comment to give it higher visibility. Under very specific circumstances, NPOT textures are valid, as is follows.

经过一些挖掘后,从技术上讲,在运行2.0 ES的较新的iOS硬件中启用了NPOT纹理,但是使用极为有限.具体来说,您必须使用具有钳位到边缘的线性滤波,并且不能进行mipmapping.这限制了您的使用,并且在大多数情况下,二次幂图像仍然会更高效/具有更高的帧速率.

After a bit of digging, NPOT textures are technically enabled in the newer iOS hardware running 2.0 ES, but with extremely limited use. Specifically, you must use linear filtering with clamp-to-edge, and no mipmapping. This limits your use, and in most cases a power-of-two image would still be more efficient/have higher framerates.

这篇关于iphone opengl es 2.0非二的幂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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