glDrawElements weirdness

I have discovered that even though java does not support unsigned types it is necessary to use unsigned types in describing the index array in glDrawElements()

example:
short[] index = {1, 2, 3};

// will not work
gl.glDrawElements(GL.GL_TRIANGLES, index.length, GL.GL_SHORT, index);

// will work
gl.glDrawElements(GL.GL_TRIANGLES, index.length, GL.GL_UNSIGNED_SHORT, index);

The type argument is used just to indicate the size of the data to expect, so signed or unsigned should be the same size but the GL spec says unsigned only otherwise it’ll throw an error and ignore the command.

And while Java only supports signed values the underlying GL implementation will still treat the values as unsigned so if you have your bit patterns all figured out correctly you can still supply it with the upper half of the 2^n index values :-).