umlaeute/Gem — pull request #55 by jptrkz (2014-09-09 01:40:14+00:00)
Title: gemvertexbuffer_shader

Adds a dynamic std::vector object array for GLSL attribute variables.

NOTE - an error with a "reset_attributes" msg. The console gives "GL: invalid enumerant". I am unable to find where this occurs but the function still works.

The vector array changes in size as new variables are added. If a variable already exists as a VBO, the pd-msg updates the attribute with the pd-table provided. If the vert/frag file is changed, the attribute array in gemvertexbuffer can be reset with a pd-msg and refilled.

The aim in creating these extra VBOs is to give *each* geo-primitive in gemvertexbuffer the full potential of all permutations of the shader's parameters. Variables changed with pd-msgs to glsl_program affect *all* geo-primitives in the gemvertexbuffer the same. The attribute array removes the need for multiple instances of glsl_program and gemvertexbuffer for small changes of a shader.
This method is almost perfect - the only drawback is that the "uniform" parameter does not have an equivalent to glVertexAttribPointer and cannot be set-up like the built-in and generic attributes (uniforms are once per primitive). If a user wants to have each uniform variable different for each primitive, these uniform variables must changed to attributes in the vert/frag files. This is a bit awkward since all variables intended to be used only for the frag file must be defined and then converted to "varying" in the vert file.