I have an array of indices with a length of 97536, when it gets to 16,129 it gives me a null pointer exception. Index[] indices = new Index[6 * (VERTEX_COUNT - 1) * (VERTEX_COUNT * 1)];
. I then have a double for loop and a pointer to loop through all of the objects in the array and initial them.
int pointer = 0;
for(int gz = 0; gz < VERTEX_COUNT - 1; gz++)
{
for(int gx = 0; gx < VERTEX_COUNT - 1; gx++)
{
indices[pointer] = new Index((gz * VERTEX_COUNT) + gx);
indices[pointer] = new Index(((gz + 1) * VERTEX_COUNT) + gx);
indices[pointer] = new Index(((gz * VERTEX_COUNT) + gx) + 1);
indices[pointer] = new Index(((gz * VERTEX_COUNT) + gx) + 1);
indices[pointer] = new Index(((gz + 1) * VERTEX_COUNT) + gx);
indices[pointer] = new Index((((gz + 1) * VERTEX_COUNT) + gx) + 1);
pointer++;
}
}
This error did not come up when the array was a int[] indices
. I am very confused and wondering why the null pointer exception happens at 16129. The first thought was that the for loops never reach the correct number, if so how would I calculate that?
- Thanks in advance