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
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.
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);
There can be multiple issues with your image:
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.
When you want to enable Mipmap filtering, then you need to enable it using boolean genMipMaps which tells libgdx whether to generate mapmaps.
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