AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

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

AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

millerni456
Hi everyone,

I've been experiencing some strange behavior when working the AWTTextureIO.newTexture() function.
I haved loaded a texture atlas of 32x32 pixel images and I used BufferedImage.getSubimage() to obtain each individual texture.
The atlas only had 4 images, but I was able to use all images properly.

When I changed to 64x64 pixels (or 32x32 on a Mac), the textures objects behave strangely.

For 64x64, my first texture becomes nothing and the other 3 become the image represented by the first texture.  Does this make sense?
On the mac, the first two textures become something random (I really don't know what happened, but I had flickering artifacts that seem to contain images of what was on my JFrame), and the 2nd two images work properly.

I've also read here that there is a bug that was found:
https://jogamp.org/bugzilla/show_bug.cgi?id=823


So... what's going on here?  Is there really an issue with this function?  My code should be fine (checked it more than enough times).  If there really is a bug with this function, how should I obtain a subimage in the meantime, while the bug is being fixed?

Thanks much! :)
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

gouessej
Administrator
Use TextureIO instead of AWTTextureIO.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

millerni456
Hi gouessej,

It looks like in the past it was possible to use TextureIO to load a buffered image.  I do not see this functionality in the most recent version for JOGL.

What do you recommend here?  I need need load a sub image, and I have been getting that sub image using javax.imageio.ImageIO.  How should I go about using TextureIO to load a subimage?

Also, what is the difference between TextureIO and AWTTextureIO? Is AWTTextureIO deprecated?  According to the Javadoc, AWTTextureIO extends TextureIO and gives funcitonality for working with buffered images.

I'm a little confused to say the least

Current Javadoc:
http://jogamp.org/deployment/jogamp-current/javadoc/jogl/javadoc/

Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

gouessej
Administrator
You should have looked at the source code. TextureIO from JOGL 1 has become AWTTextureIO in JOGL 2. TextureIO in JOGL 2 doesn't use AWT, it relies on our loaders which outperform those of AWT. You can create a TextureData and use it to create a BufferedImage. I don't remember exactly how, I just remember that you can use the format and the buffer that contains the pixels.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

millerni456
It seems you may have misunderstood me.  The reason I need a sub-image, ultimately, is to create an OpenGL texture object out of it.

Looking at the current JOGL release, here are the methods for TextureIO and AWTTextureIO.

TextureIO
TextureIO Methods

AWTTextureIO
AWTTextureIO Methods

I only see creating textures or texture data from files/URL's/streams for TextureIO, while seeing buffered images for AWTTextureIO.
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

jmaasing
Usually engines upload the atlas as one texture to the GPU memory and then tell the shader which subimage to use when rendering. Less overhead in that way.
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() with a BufferedImage.getSubimage()

millerni456
I think my application will fall into the 'unusual' category.  I will have many texture atlases, and images for multiple texture atlas could be loaded at the same time.  There will be hundreds of images to select from and I simply cannot load entire atlases at the same time.  I need to manage a small number of images that are loaded/unloaded as they are needed.  Also, this application is time-sensitive, so I need to be able to load/unload these images as fast as possible.