纹理大小的限制?安卓开放 GL ES 2.0 [英] Limitation on texture size? Android Open GL ES 2.0

查看:29
本文介绍了纹理大小的限制?安卓开放 GL ES 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道可以在任何 Android Opengl Es 2.0 项目中使用的纹理大小是否有任何限制.我知道拥有大小为 4096x4096 的巨大纹理的意义不大,因为它是在小屏幕上呈现的.但是如果需要在运行时在许多纹理之间切换怎么办?如果我想要一个纹理图集来进行快速单次上传,而不是多个较小的纹理上传.请让我知道您在这方面的想法.

I would like to know if there is any kind of limitation on the texture size that can be used in any Android Opengl Es 2.0 projects. I understand that having a huge texture of size 4096x4096 is a bit meaning less as it is rendered on a small screen. But What if the requirement is to switch between many textures at run time? And If I want to have a texture atlas to do a quick single upload instead of multiple smaller texture upload. Please let me know your ideas in this regards.

此外,我确信设备可以处理的图像大小必须受到限制,因为设备上的内存是有限的.但我想知道它是基于分辨率还是基于大小.我的意思是,如果设备的图像大小限制为 1024x1024,它可以处理大小为 2048x2048 的压缩纹理,该纹理的大小大约与未压缩的 1024x1024 大小相同.

Also I am sure there has to be a limitation on the size of image that can be processed by a device, as the memory on the device is limited. But I would like to know if it is resolution based or is it size based. I mean if a device has a limitation of 1024x1024 image size can it handle a compressed texture of size 2048x2048 that would be of same size approx as uncompressed 1024x1024.

另外请在一般情况下告诉我,通常运行 android 2.2 及更高版本的普通设备对纹理大小或分辨率的限制是多少.

Also please let me know on an general basis usually how much the limitation on texture size or resolution normal devices running android 2.2 and above would be.

另外,请告诉我在 opengles 2.0 中处理高分辨率图像时是否有任何最佳做法,以便在加载时间和运行时间都获得最佳性能.

Also please let me know if there are any best practices when handling high resolution images in opengles 2.0 to get best performance in both load time and also run time.

推荐答案

纹理大小存在硬件限制.要手动查找它们,您可以访问诸如 之类的站点glbenchmark.com(此处显示有关 google galaxy nexus 的详细信息).
要从您的代码中自动找到最大大小,您可以使用类似:

There is a hardware limitation on the texture sizes. To manually look them up, you can go to a site such as glbenchmark.com (Here displaying details about google galaxy nexus).
To automatically find the maximum size from your code, you can use something like:

int[] max = new int[1];
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, max, 0); //put the maximum texture size in the array.

(对于GL10,但对于GLES20也有同样的方法)

(For GL10, but the same method exists for GLES20)

当涉及到图像的处理编辑时,您通常使用 Bitmap 在 android 中工作时.这包含图像的未压缩值,因此取决于分辨率.但是,推荐为您的 openGL 应用程序使用压缩纹理,因为这样可以提高内存使用效率(请注意,您无法修改这些压缩纹理).
上一个链接:

When it comes to the processing or editing of an image you usually use an instance of Bitmap when working in android. This holds the uncompressed values of your image and is thus resolution dependant. However, it is recommended that you use compressed textures for your openGL applications as this improves the memory-use efficiency (note that you cannot modify these compressed textures).
From the previous link:

纹理压缩可以显着提高您的性能OpenGL 应用程序通过减少内存需求并制作更多有效利用内存带宽.Android 框架提供支持 ETC1 压缩格式作为标准功能 [...]

Texture compression can significantly increase the performance of your OpenGL application by reducing memory requirements and making more efficient use of memory bandwidth. The Android framework provides support for the ETC1 compression format as a standard feature [...]

您应该查看本文档,其中包含许多良好做法和提示关于纹理加载和使用.作者明确写道:

You should take a look at this document which contains many good practices and hints about texture loading and usage. The author explicitly writes:

最佳做法:使用 ETC 进行纹理压缩.

Best practice: Use ETC for texture compression.

最佳做法:确保您的几何和纹理分辨率适合它们显示的大小.不要使用 1k x 1k屏幕上最多 500 像素宽的东西的纹理.这几何也一样.

Best practice: Make sure your geometry and texture resolutions are appropriate for the size they're displayed at. Don't use a 1k x 1k texture for something that's at most 500 pixels wide on screen. The same for geometry.

这篇关于纹理大小的限制?安卓开放 GL ES 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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