OpenGL ES 2.0的质地没有显示某些设备上质地、设备、OpenGL、ES

2023-09-06 13:24:24 作者:女生唯美阳光安静

我发现了一个三维图形架构的Andr​​oid名为拉贾瓦利,我正在学习如何使用它。我跟着最基本的教程被渲染shpere对象的质地1024×512尺寸的JPG图片。它工作得很好的Galaxy Nexus的,但它并没有对银河队球星GB70工作。

I found a 3D graphics framework for Android called Rajawali and I am learning how to use it. I followed the most basic tutorial which is rendering a shpere object with a 1024x512 size jpg image for the texture. It worked fine on Galaxy Nexus, but it didn't work on the Galaxy Player GB70.

当我说这没有工作,我的意思是对象出现,但质地不渲染。最后,我改变了创建纹理时,我使用的拉贾瓦利框架的一些参数,并得到它的工作。以下是我发现了。

When I say it didn't work, I mean that the object appears but the texture is not rendered. Eventually, I changed some parameters that I use for the Rajawali framework when creating textures and got it to work. Here is what I found out.

原因是从哪里 GL_TEXTURE_MIN_FILTER 正在设定未来。在下列四个值

The cause was coming from where the GL_TEXTURE_MIN_FILTER was being set. Among the following four values

GLES20.GL_LINEAR_MIPMAP_LINEAR
GLES20.GL_NEAREST_MIPMAP_NEAREST
GLES20.GL_LINEAR
GLES20.GL_NEAREST

GL_TEXTURE_MIN_FILTER 不使用纹理映射设置过滤纹理只是渲染。因此,当 GL_TEXTURE_MIN_FILTER 设置为最后两个它的工作原理。

the texture is only rendered when GL_TEXTURE_MIN_FILTER is not set to a filter using mipmap. So when GL_TEXTURE_MIN_FILTER is set to the last two it works.

现在这里是什么,我不理解,并很好奇。当我收缩,这我使用的纹理尺寸512×512的 GL_TEXTURE_MIN_FILTER 设置无所谓的形象。最小过滤器的所有四个设置工作。

Now here is the what I don't understand and am curious about. When I shrink the image which I'm using as the texture to size 512x512 the GL_TEXTURE_MIN_FILTER settings does not matter. All four settings of the min filter works.

所以我的问题是,是否有对图像的使用分钟滤波器的纹理时的尺寸要求?比如我需要什么时候用一个形象,是方形的?其他的东西,如包装风格或磁过滤器的配置可能是一个问题?

So my question is, is there a requirement for the dimensions of the image when using min filter for the texture? Such as am I required to use an image that is square? Can other things such as the wrap style or the the configuration of the mag filter be a problem?

或者它看起来像设备的OpenGL实现的bug?

Or does it seem like a OpenGL implementation bug of the device?

推荐答案

早上好,这是一个典型的2纹理非权力的例子。

Good morning, this a typical example of non-power of 2 textures.

纹理必须是2的他们对多种原因分辨能力,这是一个非常常见的错误,并没有发生在大家陷入这个陷阱:)过我。

Textures need to be power of 2 in their resolution for a multitude of reasons, this is a very common mistake and it did happen to everybody to fall in this pitfall :) too me too.

这2个纹理无电源工作的顺利进行一些设备/ GPU的事实,仅仅依赖于OpenGL驱动程序实施,有的GPU的明确支持他们,一些别人没有,我强烈建议你去POW2纹理,以便要能够保证所有的设备的运作。

The fact that non power of 2 textures work smoothly on some devices/GPU, depends merely to the OpenGL drivers implementation, some GPUs support them clearly, some others don't, I strongly suggest you to go for pow2 textures in order to be able to guarantee the functioning on all the devices.

最后但并非最不重要的,使用2纹理非权力会导致您在GPU内存利用率cathastrophic scenarious以来,其中大部分接受非powerof2纹理的驱动程序,需要在内存中的纹理重新调整至最接近的较高功率2个因素。例如,具有520X520的质地可能导致1024×1024的实际存储器映射

Last but not least, using non power of 2 textures can lead you to a cathastrophic scenarious in GPU memory utilization since, most of the drivers which accept non-powerof2 textures, need to rescale in memory the textures to the nearest higher power of 2 factor. For instance, having a texture of 520X520 could lead to an actual memory mapping of 1024X1024.

这是你不想要的,因为在现实世界大小事项,特别是在移动设备上。

This is something you don't want because in real world "size matters", especially on mobile devices.

您可以在OpenGL的黄金书一个不错的解释,OpenGL ES 2.0的:

You can find a quite good explanation in the OpenGL Gold Book, the OpenGL ES 2.0:

在的OpenGL ES 2.0,纹理可以有非电源的二(npot)   尺寸。换句话说,宽度和高度并不需要是一个   两个电源。然而,OpenGL ES 2.0的确实对一限制   包,可以用来模式如果纹理尺寸不是的功率   二。也就是说,对于npot纹理,卷绕模式只能是   GL_CLAMP_TO_EDGE和minifica-化过滤器只能GL_NEAREST   或GL_LINEAR(换言之,不MIP-映射)。扩展   GL_OES_texture_npot放松这些限制,并允许包装模式   GL_REPEAT和GL_MIRRORED_REPEAT和还允许npot纹理   将立体映射的全套缩小过滤器。

In OpenGL ES 2.0, textures can have non-power-of-two (npot) dimensions. In other words, the width and height do not need to be a power of two. However, OpenGL ES 2.0 does have a restriction on the wrap modes that can be used if the texture dimensions are not power of two. That is, for npot textures, the wrap mode can only be GL_CLAMP_TO_EDGE and the minifica- tion filter can only be GL_NEAREST or GL_LINEAR (in other words, not mip- mapped). The extension GL_OES_texture_npot relaxes these restrictions and allows wrap modes of GL_REPEAT and GL_MIRRORED_REPEAT and also allows npot textures to be mipmapped with the full set of minification filters.

我建议你,因为它确实相当不错覆盖到这个话题评价这本书。

I suggest you to evaluate this book since it does a quite decent coverage to this topic.