Search code examples
androidlibgdx

Libgdx - using MipMaps


TextureLoader.TextureParameter param = new TextureLoader.TextureParameter();
    param.minFilter = Texture.TextureFilter.MipMapLinearNearest;
    param.magFilter = Texture.TextureFilter.Nearest;
    param.genMipMaps = true;

    manager.load("MainMenu.pack", TextureAtlas.class);

    manager.load("GameScreen/player.png", Texture.class, param);
    manager.load("GameScreen/obstacle.png", Texture.class, param);
    manager.load("GameScreen/star.png", Texture.class, param);

The MainMenu also has it's filter's set in the .pack file.

Now is this all done automatic? Or do I have to manually tell the app to use mipmaps, which I probably must, but how do I do that?


Solution

  • Due to official LibGDX wiki:

    When opting to use mipmaps, the Texture will create them at instantiation time. MipMaps are pre-calculated, optimized resized copies of the same image to save on computation time when resizing the texture to fit a rectangle. Smaller (halved) copies of the same image are created and uploaded to the GPU and used for different sized geometries instead of being shrunk on the fly. It adds to memory consumption but makes rendering faster.

    So yup - they are being generated automatically.