Hello all. I'm porting a piece of code from old JOGL to new JOGL and all my textures are inverted. I have to change my texture matrix to make it fit. And the textures applied on quadric sphere (where texture matrix are autogenerated) cannot be fixed without altering the texture itself.
What am I doing wrong ??? It look like the coordinate system was wrong or something. Thanks for the help! |
Administrator
|
With "inverted" u mean "upside down" ? Thats normal. Its OpenGLs standard coordinate system for textures and was like this since the beginning. Take a look here:
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/ Under "12. OpenGL's Lower Left Origin" they state: "Another common pitfall related to 2D rendering APIs having an upper left-hand coordinate system is that 2D image file formats start the image at the top scan line, not the bottom scan line. OpenGL assumes images start at the bottom scan line by default." So it has nothing to do with old/new JOGL. My lucky guess is u forgot to migrate/port some kind of custom "texture flipping"-code that does the magic for u in the background. |
In reply to this post by Arthur
are you using the TextureIO utilities? TextureData and Texture have both isVerticallyFlipped() methods to indicate if the texture needs to be flipped or not. (don't ask me why it was introduced, TextureIO probably just reads the file as is and writes it to the buffer) @Sven ? -michael On 07/14/2010 03:54 AM, Arthur [via jogamp] wrote: Hello all. I'm porting a piece of code from old JOGL to new JOGL and all my textures are inverted. I have to change my texture matrix to make it fit. And the textures applied on quadric sphere (where texture matrix are autogenerated) cannot be fixed without altering the texture itself. |
In reply to this post by Demoscene Passivist
Actually, not it is flipped horizontally. I'm displaying earth texture on a sphere, and east coast is on the west and vice-versa. I am already correcting for the verticalflip using rotation transform.
As for the isVerticallyFlipped() of Texture/TextureIO/TextureData, this is only a getter. Thus should i assume that i need to do it myself ? Is there a way to automate vertical flip in the load of the texture ? Thanks, Arthur |
Administrator
|
Unfortunately u have to flip it urself (at least as far as I know) ... I'm using this little helper method:
private static BufferedImage flipBufferedImageVertical(BufferedImage inBufferedImage) { int tWidth = inBufferedImage.getWidth(); int tHeight = inBufferedImage.getHeight(); BufferedImage tFlippedBufferedImage = new BufferedImage(tWidth, tHeight, inBufferedImage.getType()); Graphics2D tG2D = tFlippedBufferedImage.createGraphics(); tG2D.drawImage(inBufferedImage, 0, 0, tWidth, tHeight, 0, tHeight, tWidth, 0, null); tG2D.dispose(); return tFlippedBufferedImage; } ... and then this to conveniently do the vertical fiip: BufferedImage tBufferedImage = ImageIO.read(newBufferedInputStream((newObject()).getClass().getResourceAsStream(inFileName))); AWTTextureIO.newTexture(GLProfile.getDefault(), flipBufferedImageVertical(tBufferedImage), true); |
Administrator
|
It seems everything is already there, u just have to find it :)
com.jogamp.opengl.util.awt.ImageUtil public static void flipImageVertically(BufferedImage image) Flips the supplied BufferedImage vertically. This is often a necessary conversion step to display a Java2D image correctly with OpenGL and vice versa. |
On 07/19/2010 01:44 PM, Demoscene Passivist [via jogamp] wrote: It seems everything is already there, u just have to find it :) |
Free forum by Nabble | Edit this page |