I am using OpenGL3.2 Core Profile on OSX. And I want to do instanced drawing (glDrawArraysInstanced), where I pass a matrix for each instance.
My vertex shader builds just fine:
#version 150
in mediump vec4 position;
in mediump mat4 trf;
in lowp vec4 rgb;
out lowp vec4 colour;
uniform highp mat4 modelcamviewprojmat;
void main()
{
mediump vec4 tpos = trf * position;
gl_Position = modelcamviewprojmat * tpos;
colour = rgb;
}
The binding of 'trf' went fine:
glBindAttribLocation(program, ATTRIB_TRF, "trf" );
But how can I pass in my data? glVertexAttribPointer can not pass values larger than 4 floats. So this call fails:
glVertexAttribPointer( ATTRIB_TRF, 16, GL_FLOAT, 0, 16 * sizeof(float), ... );
I suspect that I need to replace it with 4 calls to glVertexAttribPointer, each passing 4 floats. But what value could I use for 'index' (first parm)? Do I need to use 4 vector attributes instead, and assemble the four vectors in GLSL vertex shader? If so, what kind of GLSL code accomplishes this? Or can I use the return value from BindAttribLocation and use val+0, val+1, val+2 and val+3 for all the rows?