Limitation on texture size? Android Open GL ES 2.0
Asked Answered
L

1

7

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.

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.

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.

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.

Lambdacism answered 20/12, 2011 at 9:22 Comment(0)
W
23

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.

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

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:

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:

Best practice: Use ETC for texture compression.

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.

Worsham answered 20/12, 2011 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.