libgdx texture filters and mipmap

后端 未结 4 1552
慢半拍i
慢半拍i 2021-01-12 05:34

When I try to use mipmap filtering in LibGDX, none of the images appear.

I\'m new to LibGDX, and I have a simple 2d scene with three rotating, scaled circles. In

相关标签:
4条回答
  • 2021-01-12 05:54

    Try using the same minFilter and maxFilter. I had a similiar problem and if I put TextureFilter.Linear, TextureFilter.Linear or both MipMap the problem is solved. Hope this helps.

    0 讨论(0)
  • 2021-01-12 06:12

    Just like Mitesh said in his answer mipmaps filters doesn't work because you are not telling Libgdx to generate mipmaps.

    if you are using assets manager the code will be something like this

     TextureParameter param = new TextureParameter();
     param.genMipMaps = true; // enabling mipmaps
    
     manager.load("path/to/texfile.png", Texture.class, param);
    
     Texture tex = manager.get("path/to/texfile.png", Texture.class);
     tex.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
    
    0 讨论(0)
  • 2021-01-12 06:14

    There can be multiple issues with your image:

    1. It should be power of 2, if you are using an image with size like 354X420, it won't work. In this case you need to take an image of 512X512 or any other power of 2.

    2. When you want to enable Mipmap filtering, then you need to enable it using boolean genMipMaps which tells libgdx whether to generate mapmaps.

    0 讨论(0)
  • 2021-01-12 06:17

    I had this same problem, and the fix turned out to be insanely simple. When you create a Texture, you need to specify that it uses mipmaps.

    All you have to do is pass a second parameter to the Texture constructor like this:

    Texture myTexture = new Texture(Gdx.files.internal("myImage.png"), true);

    You can view all the Texture class constructors in the API docs here: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Texture.html

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