I have a program that uses the TextureIO class to repeatedly read a BufferedImage into textures, and I’m encountering a problem: every time it reads the image again, a vertical flip occurs. I presume this is a side-effect of the functionality that flips the images vertically, but it doesn’t seem like this should be happening - for one thing, how does it even happen? the Texture isn’t stored over each render loop, so it seems to me that the TextureIO.read method must be actually flipping the image itself, somehow. Is this known behavior, or should I delve into the TextureIO source to figure out why this is happening?
Yes, the TextureIO code is doing this. Please feel free to file a bug about it. Ideally it should not mutate the incoming BufferedImages.
strange… I cannot recall that it flipped images when I was testing TextureIO months ago :-\
It definitely did - I found the point in the code where it does so (479 in TextureData.java), and posted a patch on how I rectified it (issue # 238)… I’m uncertain why the flipping was in there, though - its possible some other part of the texture package may expect it to be flipped, in which case this patch would screw that up…
I suspect that the flaw was in my testing program. I probably assumed the flipping behaviour as correct and designed the program to work with it. I recall that I was drawing several textures manually by first composing some BufferedImages and then uploading them to the video memory. It is likely that I made the mistake already when I was drawing on the BufferedImages such that the final result looked as expected… I have to check the code again to be 100% sure though. Unfortunately I do not have it on my current machine anymore.
Johannes
The BufferedImage flipping code was added to avoid using flipped texture coordinates as much as possible, since they may be confusing to applications. I’m pretty sure it’s possible to do this in one or more ways without mutating the incoming BufferedImage and will try to get to this later this week.
Ok, thanks.