Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED] TextureIO creating flipped textures?  (Read 1127 times)
0 Members and 1 Guest are viewing this topic.
Offline Cork

Junior Member




vote 6uN for OSX


« Posted 2009-09-02 23: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

Senior Newbie





« Reply #1 - Posted 2009-09-03 10: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

Junior Member




vote 6uN for OSX


« Reply #2 - Posted 2009-09-03 11: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline spiraljetty

Senior Newbie





« Reply #3 - Posted 2009-09-03 14: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

Junior Member




vote 6uN for OSX


« Reply #4 - Posted 2009-09-08 22: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]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 06:55:21

Zero Volt (29 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (26 views)
2014-07-16 23:30:00

Cero (41 views)
2014-07-16 00:42:17

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (65 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!