Avoid flipping in AWTTextureIO

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Avoid flipping in AWTTextureIO

elect
If I create a textureData through

TextureIO.newTextureData(GLProfile glp, URL url, boolean bln, String string)

everything fine

If I do through

AWTTextureIO.newTextureData(GLProfile glp, BufferedImage bi, boolean bln)

flips automatically the image

        mustFlipVertically = true;

second line in AWTTextureData.createFromImage


            test = new int[1];
            gl3.glGenTextures(1, test, 0);
            gl3.glBindTexture(GL3.GL_TEXTURE_2D, test[0]);
            {
                System.out.println("textureData.getMustFlipVertically() " + textureData.getMustFlipVertically());
                textureData.setMustFlipVertically(false);
                System.out.println("textureData.getMustFlipVertically() " + textureData.getMustFlipVertically());
                gl3.glTexImage2D(GL3.GL_TEXTURE_2D, 0, textureData.getInternalFormat(), textureData.getWidth(),
                        textureData.getHeight(), textureData.getBorder(), textureData.getPixelFormat(),
                        textureData.getPixelType(), textureData.getBuffer());
                gl3.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_BASE_LEVEL, 0);
                gl3.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_MAX_LEVEL, 0);
            }
            gl3.glBindTexture(GL3.GL_TEXTURE_2D, 0);


this print

true
false

but the texture is still rendered flipped
Reply | Threaded
Open this post in threaded view
|

Re: Avoid flipping in AWTTextureIO

gouessej
Administrator
Hi

I had the same kind of trouble when I ported the alpha version of my game to JOGL 2. mustFlipVertically is an hint used by the Texture class. If you use TextureData without Texture, you have to look at the hint to decide whether flipping the texture coordinates or the data. I flip the data in JogAmp's Ardor3D Continuation, feel free to look at my code.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Avoid flipping in AWTTextureIO

elect
I solved using the utility

        ImageUtil.flipImageVertically(bufferedImage);


Reply | Threaded
Open this post in threaded view
|

Re: Avoid flipping in AWTTextureIO

gouessej
Administrator
It's a good method but it is slower than what I do in JogAmp's Ardor3D Continuation. I assume it's enough for you.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Avoid flipping in AWTTextureIO

elect
gouessej wrote
It's a good method but it is slower than what I do in JogAmp's Ardor3D Continuation. I assume it's enough for you.
I am using it for icons 100x25 pixels, I guess it is ok