Limitation on texture size? Android Open GL ES 2.0

前端 未结 1 367
臣服心动
臣服心动 2020-11-29 08:09

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 o

相关标签:
1条回答
  • 2020-11-29 08:19

    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.

    0 讨论(0)
提交回复
热议问题