I've been trying to resolve this issue I have been having with displaying a texture correctly on my libgdx desktop program.
I have an Orthographic camera with which when I set as:
camera.setOrtho(false);
And when I set it as:
camera.setOrtho(true);
The red image is drawn with a SpriteBatch:
batch.draw(texture, x, y, width, height);
While the white image is drawn from individual points plotted based on if their alpha value was 1.
TextureData td = texture.getTextureData();
td.prepare;
Pixmap map = td.consumePixmap();
for (int i = 0; i < map.getWidth(); i++)
for (int j = 0; j < map.getHeight(); j++)
if (new Color(map.getPixel(i, j)).a == 1)
points.add(new Point(i, j));
Above is the code used to get all the non-transparent pixels. They are displayed as the white image, and seem to be the inverse of the original texture.
However, the points plotted and the image itself is always an inverse of one another.
Is there any way of resolving this issue?
Thank you.
PS: I've tried multiple ways of trying to fix this:
- Using Sprites and flipping them
- Using TextureRegions and flipping them
Absolutely nothing seems to work.
setOrtho
method do? – BDL