Login  Register

Re: Where is glVertexAttribIPointer that doesn't take a Buffer?

Posted by Jeff Quigley on Sep 03, 2012; 1:50am
URL: https://forum.jogamp.org/Where-is-glVertexAttribIPointer-that-doesn-t-take-a-Buffer-tp4026005p4026011.html

To make it clearer:

// in the shader:
in ivec2 someAttribute;

// in Java:
int[] attributeData = [a lot of ints];
int attributeLocation = gl.glGetAttribLocation(shaderProgram, "someAttribute");
gl.glVertexAttribPointer(attributeLocation, 2, GL.GL_FLOAT, false, stride, 0);
gl.glBufferData(GL.GL_ARRAY_BUFFER, count, IntBuffer.wrap(attributeData), GL2.GL_STREAM_DRAW);


^^ This works correctly.  I provide ints, I say I'm providing floats, and I end up with the right ivec2.  If I say I'm providing ints:
gl.glVertexAttribPointer(attributeLocation, 2, GL.GL_UNSIGNED_INT, false, stride, 0);
or
gl.glVertexAttribPointer(attributeLocation, 2, GL3.GL_INT, false, stride, 0);

then it does not work correctly.  The ivec2 (I also tried uvec2, with the same result) is supposed to contain (x, y) but instead it apparently contains (floatBitsToInt(x), floatBitsToInt(y)).