Login  Register

Re: Loading texture error

Posted by Sven Gothel on Jul 06, 2010; 12:26pm
URL: https://forum.jogamp.org/Loading-texture-error-tp942252p946280.html

On Monday, July 05, 2010 03:31:43 GuilhermeAmorim [via jogamp] wrote:

>
> Thanks you for the attention
>
> After sometime reading the documentation I updating the project to the new
> version of the library I almost cried when the issue reoccurred. hehe
>
> It's strange since I'm learning JOGL with NeHe's Tutorials and they have the
> JOGL version of this lesson that doesn't work as well
> but they posted, so I think it supposedly should work.
>
> Anyway,
> I'll post this issue bugzilla, and I'm attaching the code here too.
>
> Any solution would be welcome.
>
Thank you.

To not allow any insecure memory access,
we verify all memory/DMA transfers by tracking the approriate state
of the objects. You have experienced this with your posted exception.
.. com.sun.gluegen.runtime.BufferFactory.rangeCheckBytes

I fetched your attachment, made the little conversion necessary for JOGL2
(sun -> jogamp, and the BufferUtils -> Buffer), plus added the debug and trace pipeline.
See attachement #1.

This shows me the following:

+++

Info: XInitThreads() called for concurrent Thread support
glGenTextures(<int> 0x1, <[I>, <int> 0x0)
glBindTexture(<int> 0xDE1, <int> 0x1)
glTexImage2D(<int> 0xDE1, <int> 0x0, <int> 0x3, <int> 0x100, <int> 0x100, <int> 0x0, <int> 0x1907, <int> 0x1401, <java.nio.Buffer> java.nio.DirectByteBuffer[pos=196608 lim=196608 cap=196608])Exception in thread "Timer-0" javax.media.opengl.GLException: java.lang.IndexOutOfBoundsException: Required 196608 remaining bytes in buffer, only had 0

+++

As you can see, we calculate the proper byte size of 196608, which is to be expected,
but you buffer can't offer any - since it's position is at it's limit.

A simple buffer.rewind() solved your bug, so we can read all required bytes,
see attachment #2.

Now the output is:

+++

Info: XInitThreads() called for concurrent Thread support
glGenTextures(<int> 0x1, <[I>, <int> 0x0)
glBindTexture(<int> 0xDE1, <int> 0x1)
glTexImage2D(<int> 0xDE1, <int> 0x0, <int> 0x3, <int> 0x100, <int> 0x100, <int> 0x0, <int> 0x1907, <int> 0x1401, <java.nio.Buffer> java.nio.DirectByteBuffer[pos=0 lim=196608 cap=196608])
glTexParameteri(<int> 0xDE1, <int> 0x2801, <int> 0x2601)
glTexParameteri(<int> 0xDE1, <int> 0x2800, <int> 0x2600)
glShadeModel(<int> 0x1D01)
...

+++

And the cube is no more yellow :)

~Sven


> Attachments:
> http://jogamp.762907.n3.nabble.com/file/n943281/JOGL1.zip JOGL1.zip
>
> ______________________________________

Main-1.diff (1K) Download Attachment
Main-2.diff (1K) Download Attachment