I am creating a single pixel with a specified color using a common method createSinglePixelTexture() as I have mentioned below.
Question: 1. Do I need to dispose "singlePixelPixmap" and texture "t" ? 2. If I need to dispose that where I can dispose it ?
singlePixelTexture = createSinglePixelTexture(0.129f, 0.129f, 0.129f, .7f);
private Texture createSinglePixelTexture(float r,float g,float b,float a) {
Pixmap singlePixelPixmap;
singlePixelPixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
singlePixelPixmap.setColor(r, g, b, a);
singlePixelPixmap.fill();
PixmapTextureData textureData = new PixmapTextureData(singlePixelPixmap, Pixmap.Format.RGBA8888, false, false, true);
Texture t = new Texture(textureData);
t.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
return t;
}
PixmapTextureData; it's entirely optional.Texture with a Pixmap, you can dispose the Pixmap. So you can insert the disposal of everything but the texture just before the return.Texture, it cannot be drawn. Do not dispose t unless you are SURE you will never try to draw it again.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With