Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi,
since TextureIO have some performances problems, (http://stackoverflow.com/questions/1927419/loading-pngs-into-opengl-performance-issues-java-jogl-much-slower-than-c-sha) I would like to load textures from .PNG without it If I try to load it like this try { File file = new File(getClass().getResource("/ec/data/textures/" + textureName).toURI()); bufferedImage = ImageIO.read(file); ImageIO.write(bufferedImage, "png", byteArrayOutputStream); } catch (URISyntaxException | IOException ex) { Logger.getLogger(EC_Mesh.class.getName()).log(Level.SEVERE, null, ex); } byte[] bs = byteArrayOutputStream.toByteArray(); texture = new int[1]; gl3.glGenTextures(1, texture, 0); gl3.glBindTexture(GL3.GL_TEXTURE_2D, texture[0]); { gl3.glTexImage2D(GL3.GL_TEXTURE_2D, 0, GL3.GL_RGBA, bufferedImage.getWidth(), bufferedImage.getHeight(), 0, GL3.GL_RGBA, GL3.GL_UNSIGNED_BYTE, GLBuffers.newDirectByteBuffer(bs)); I get an error Caused by: java.lang.IndexOutOfBoundsException: Required 16777216 remaining bytes in buffer, only had 314199 My png should be a 32b RGBA 2048x2048, then 4B aligned, then 2048 * 2048 * 4 = 16777216... so why do I get 314199? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
ImageIO isn't faster than TextureIO as far as I know. StackOverflow isn't a good source of information about JOGL. People can vote but more votes don't mean that what they write is true. A misuse of TextureIO can cause slowdowns. Please don't be so peremptory when quoting StackOverflow in the future and this answer is better on my view:
http://stackoverflow.com/a/2100197 Moreover, you quote a comment written in 2010 at the time of JOGL 1, LOL. We didn't use our own PNG loader at this time. TextureIO in JOGL 1 is closer from AWTTextureIO in JOGL 2, not TextureIO in JOGL 2.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
On 02/28/2014 03:03 PM, gouessej [via jogamp] wrote:
> ImageIO isn't faster than TextureIO as far as I know. TextureIO now uses PNGJ (own branch) to load PNG files and our own JPEG decoder for JPEG files. Non representative tests results show that our solution exposes a better performance in decoding, as well as it removes the need to vertical flip the image. ~Sven |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by elect
On 02/28/2014 02:50 PM, elect [via jogamp] wrote:
> Hi, > I get an error > > /Caused by: java.lang.IndexOutOfBoundsException: Required 16777216 remaining > bytes in buffer, only had 314199/ > > My png should be a 32b RGBA 2048x2048, then 4B aligned, then 2048 * 2048 * 4 = > 16777216... so why do I get 314199? Pls have a look at GLBuffers, which provides tools to calculate the required memory for the texture considering pixelformat, stride .. etc. ~Sven |
Free forum by Nabble | Edit this page |