Trying to debug the example number 14 of the arcsyn tutorials
https://github.com/elect86/modern-jogl-examples/tree/master/modern-jogl-examples/src/tut14/materialTextureI am stuck on creating the gaussian texture, so I decreased manually some dimension in order to analyze smaller quantity of data, in this case cosAngleResolution=1 and shininessResolution=128
private int createGaussianTexture(GL3 gl3, int cosAngleResolution, int shininessResolution) {
byte[] textureData = buildGaussianData(cosAngleResolution, shininessResolution);
System.out.println("textureData.length " + textureData.length);
int[] gaussTexture = new int[1];
gl3.glGenTextures(1, gaussTexture, 0);
gl3.glBindTexture(GL3.GL_TEXTURE_2D, gaussTexture[0]);
{
ByteBuffer byteBuffer = GLBuffers.newDirectByteBuffer(textureData);
System.out.println("byteBuffer " + byteBuffer.toString());
System.out.println("cosAngleResolution " + cosAngleResolution + " shininessResolution " + shininessResolution);
gl3.glTexImage2D(GL3.GL_TEXTURE_2D, 0, GL3.GL_R8, cosAngleResolution, shininessResolution,
0, GL3.GL_RED, GL3.GL_UNSIGNED_BYTE, byteBuffer);
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);
return gaussTexture[0];
}the glTexImage2D returns
Caused by: java.lang.IndexOutOfBoundsException: Required 509 remaining bytes in buffer, only had 128
And this is the output
textureData.length 128
byteBuffer java.nio.DirectByteBuffer[pos=0 lim=128 cap=128]
cosAngleResolution 1 shininessResolution 128
I really dont get why it expects 509 bytes in the buffer since width is 1 and height is 128..