Textures upside down - using Point Sprites

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

Textures upside down - using Point Sprites

lukej
I noticed a problem when I updated from JOGL 1.1 to JOGL 2.0.  Now all of my textures have been turned upside down.  I understand this is a common problem that can usually be fixed by adjusting the specification of your texture coordinates.  However, I have no texture coordinates.  I am rendering the textures as point sprites.

I use TextureIO.newTexture to load the texture with this method:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/TextureIO.html#newTexture%28java.io.InputStream,%20boolean,%20java.lang.String%29

Then I call bind, on the texture, and later I use glDrawElements to draw my VBO's while the texture is bound.

I'm not seeing anywhere I can flip my texture (other than while reading it in).

Am I missing something?
Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

lukej
I solved my own problem by replacing a call to TextureIO.newTexture with:
1. Read image into BufferedImage using ImageIO.read
2. Create TextureData from BufferedImage using AWTTextureIO.newTextureData
3. Create Texture from TextureData using the Texture constructor

The texture is no longer flipped.  I'm wondering, is this expected behavior, or is there a bug in TextureIO.newTexture?
Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

Sven Gothel
Administrator
On 05/16/2012 09:48 PM, lukej [via jogamp] wrote:
> I solved my own problem by replacing a call to TextureIO.newTexture with:
> 1. Read image into BufferedImage using ImageIO.read
> 2. Create TextureData from BufferedImage using AWTTextureIO.newTextureData
> 3. Create Texture from TextureData using the Texture constructor
>
> The texture is no longer flipped.  I'm wondering, is this expected behavior,
> or is there a bug in TextureIO.newTexture?

Your texture is a PNG file ?

If so, we use our own PNG texture I/O now
and maybe we don't set the 'flip' flag right ..

Pls provide a simple unit test for this,
and/or create a bugzilla entry. This is a regression.

~Sven

--
health & wealth
mailto:[hidden email] ; http://jausoft.com
Timezone: Shanghai
Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

waste
I got the same issue. All my textures are PNG and all of them are upside down. More of it - something is wrong with indexed color PNG images. When I try load texture via:

Texture t = TextureIO.newTexture(new File("images/skybox.png"), false);

and when skybox is 2/16/256 colors only, everything is crashing with array index out of bound exception.
Is there any bug already opened for it?

MM
Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

Sven Gothel
Administrator
On 10/01/2012 11:33 PM, mm [via jogamp] wrote:
> I got the same issue. All my textures are PNG and all of them are upside down.

See: <http://forum.jogamp.org/png-s-flipped-vertically-td4025452.html#a4025457>

The upside-down issue, is a non issue.
The texture writer stores it properly 1:1 in OpenGL space.

This may be different than what AWT did, pls check our so many unit tests
which create screenshots, check call-reference of UITestCase.snapshot(..)
or 'GLReadBufferUtil' for example.
All results have proper orientation.

If you can produce a unit test shows wrong orientation by API error,
pls attach it to a new bug report.

> More of it - something is wrong with indexed color PNG images. When I try load
> texture via:
>
> Texture t = TextureIO.newTexture(new File("images/skybox.png"), false);
>
> and when skybox is 2/16/256 colors only, everything is crashing with array
> index out of bound exception.
> Is there any bug already opened for it?

We are using the PNGJ package as our default AWT-less PNG backend.

It is possible that some PNG formats are not properly supported by us,
let's consider this a bug - in case PNGJ supports them.
PNGJ claims to support indexed PNG files, so we may need to fix this.

Currently (see above / unit tests), we only test RGB and RGBA 24/32 bit
PNG images.
It would be great if you can produce a few more unit tests
demonstrating the improper support.
Pls attach them in you bug report.

If anyhow possible, pls use git and send me a patch or pull request.
To do so, pls use your real name and our generic JogAmp license.

Thank you.

~Sven

>
> MM
>


signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

Gene
I'm seeing this problem, too.  So far have only found it upgrading Mac version of app to OS X Mountain Lion, so was assuming it was ML-related until noticing this thread.  

So now will also look at Windows.  Will also try to produce a small example.

Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

Sven Gothel
Administrator
On 10/08/2012 04:39 PM, Gene [via jogamp] wrote:
> I'm seeing this problem, too.  So far have only found it upgrading Mac version
> of app to OS X Mountain Lion, so was assuming it was ML-related until noticing
> this thread.  
>
> So now will also look at Windows.  Will also try to produce a small example.
>

Pls see
  <https://jogamp.org/bugzilla/show_bug.cgi?id=605#c6>

and test/enhance the unit test introduced here:

<http://jogamp.org/git/?p=jogl.git;a=commit;h=d3033e42faa909f6c1055f5ba3c7925766a3e583>

Thank you!

~Sven



signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Textures upside down - using Point Sprites

Gene
Thanks.  When I looked at it carefully, I found that this appears to be a bug fix.  PNG file textures were formerly upside down.  Now they're correct.  JPEG has remained correct throughout.

FWIW, I'm reading from PNG files stored in resources, so the call is

Texture tex = TextureIO.newTexture(getClass().getResource("/myapp/resources/foo.png"), true, TextureIO.PNG);

Cheers.