[SOLVED] TextureIO creating flipped textures?

I remeber long ago there was some discussion with flipped textures and TextureIO. Whats the current situation? I’ve only recently switched to TextureIo functionality, but today I noticed one of my .png textures is vertically flipped! Maybe they all are but I can’t tell :slight_smile:
So whats the best solution for flipping it back? .png, utility? texture co-ords?

Once you have your texture, you can call getImageTexCoords() to get the TextureCoords for your Texture and then you can use the bottom(), left(), right(), top() methods instead of specifying 0s and 1s for your texture coordinates. Also you can check the getMustFlipVertically() method and handle it yourself. I haven’t noticed any issues with images being flipped since I migrated to JOGL2 and I use the TextureCoords helper class.
HTH, sj

I pulled my model and .png back into blender and it looks fine. So it must be TextureIO class.

update: I just had a look at the method you mentioned getMustFlipVertically(). That’s returning true! which I assume means that TextureIO is doing the flipping. I would expect to see another method to correct this, but can’t find anything so far.

The TextureCoords approach won’t work for me as far as I can understand it. I’m multiplying up my texture co-ords to point to different bits of my texture. I could flip my text coords at that point, but I’d rather have the texture the right way around in the first place.

So what’s the best approach for flipping the Texture? or does it have to remain flipped for internal workings?

You could use getSubImageTexCoords(int x1, int y1, int x2, int y2) which would give you TextureCoords properly at various regions of your image texture. Or you could first load up the image as a BufferedImage and use the ImageUtils.flipImageVertically(BufferedImage image) method before using the AWTTextureIO class to turn it into a Texture using newTexture(BufferedImage image, boolean mipmap). I don’t know if there are better ways to do it. -sj

I ended up with your idea, thanks! :slight_smile:

BufferedImage image = ImageIO.read(is);
                ImageUtil.flipImageVertically(image);
                texture = AWTTextureIO.newTexture(image, true);