Ok, I've answered my own question.
The first step is to create and link the shader.
Using the existing wrapper this is simple:
self.shader = Shader(
vert = Data.vert_shader,
frag = Data.frag_shader
)
Then we query OGL for an attribute index
self.attrib = glGetAttribLocation(
self.shader.handle,
"index"
)
Then when creating the vertex list, create a string that uses the queried for attribute value
# set the attribute index
attrib_type = "%ig1f" % (self.attrib)
self.vertex_list = pyglet.graphics.vertex_list(
<snip>
(attrib_type, attribs),
)
In the vertex shader you need an attribute with the name you queried for.
In this case:
attribute float index;
You can test it by this as a varying value to the fragment shader and rendering it as the colour:
vertex shader:
varying vec4 debug;
void main()
{
<snip>
debug = vec4( index, index, index, 1.0 );
}
fragment shader:
varying vec4 debug;
void main()
{
// divide by the number of vertices
gl_FragColor = debug / vec4( 1000, 1000, 1000, 1.0 );
}
BAM!
Hope that helps someone in the future.
Cheers,
Adam