开发者

using mipmaps with ETC1 textures

开发者 https://www.devze.com 2023-04-08 14:21 出处:网络
Ive modified my code to use ETC1 textures to help lower memory usage and while the texture loads, its not automatically generating mipmaps anymore. Is this not supported for ETC1 images? Heres my code

Ive modified my code to use ETC1 textures to help lower memory usage and while the texture loads, its not automatically generating mipmaps anymore. Is this not supported for ETC1 images? Heres my code:

    //Generate three texture pointers...
    gl.glGenTextures(3, textures, 0);
    //...and bind it to our array
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
    //Create Nearest Filtered Texture
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
 //     gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR_MIPMAP_NEAREST); //problem child
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    //gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP,   GL11.GL_TRUE); problem child.
         gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
         gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);

    //Get the texture from the Android resource directory
    Log.e("Sys", "ETC1 texture support: " + ETC1Util.isETC1Supported());
    InputStream input = context.getResources().openRawResource(R.drawable.testtile);
    try {
        ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0开发者_Go百科,
                GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, input);
        Log.w("sys", "loaded!");

    } catch (IOException e) {
        Log.w("sys", "Could not load texture: " + e);
    } finally {
        try {
            input.close();
        } catch (IOException e) {
            // ignore exception thrown from close.
        }
      }


An easy way to solve this is to generate the mipmap levels with the tool you use to create your ETC1 texture (all the levels will end up in the file (eg .pvr)) and to upload each level individually.


Use this tool : http://www.malideveloper.com/developer-resources/tools/texture-compression-tool.php

The one from the Android SDK ( etc1tool ) will not generate mipmaps automatically. The mali tool can even batch convert textures to etc1/etc2 .

0

精彩评论

暂无评论...
验证码 换一张
取 消