Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  [SOLVED] TextureIO creating flipped textures?  (Read 801 times)
0 Members and 2 Guests are viewing this topic.
Offline Cork

Full Member
**

Posts: 138


vote 6uN for OSX


« on: 2009-09-02 17:43:56 »

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 Smiley
So whats the best solution for flipping it back? .png, utility? texture co-ords?
Offline spiraljetty

Jr. Member
**

Posts: 53



« Reply #1 on: 2009-09-03 04:24:46 »

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
Offline Cork

Full Member
**

Posts: 138


vote 6uN for OSX


« Reply #2 on: 2009-09-03 05:30:35 »

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?
Games published by our own members! Go get 'em!
Offline spiraljetty

Jr. Member
**

Posts: 53



« Reply #3 on: 2009-09-03 08:02:57 »

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
Offline Cork

Full Member
**

Posts: 138


vote 6uN for OSX


« Reply #4 on: 2009-09-08 16:20:20 »

I ended up with your idea, thanks! Smiley
1  
2  
3  
BufferedImage image = ImageIO.read(is);
                ImageUtil.flipImageVertically(image);
                texture = AWTTextureIO.newTexture(image, true);
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.083 seconds with 20 queries.