-void VertexSetup::update_vertex_array(const VertexArray &array, unsigned binding, unsigned divisor, bool direct) const
-{
- if(!direct)
- glBindBuffer(GL_ARRAY_BUFFER, array.get_buffer()->get_id());
-
- const VertexFormat &fmt = array.get_format();
- unsigned stride = fmt.stride();
- if(direct)
- {
- glVertexArrayVertexBuffer(id, binding, array.get_buffer()->get_id(), 0, stride);
- glVertexArrayBindingDivisor(id, binding, divisor);
- }
-
- unsigned offset = 0;
- for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++a)
- {
- unsigned sem = get_attribute_semantic(*a);
- GLenum type = get_gl_type(get_attribute_source_type(*a));
- unsigned cc = get_attribute_component_count(*a);
- if(direct)
- {
- glVertexArrayAttribFormat(id, sem, cc, type, true, offset);
- glVertexArrayAttribBinding(id, sem, binding);
- glEnableVertexArrayAttrib(id, sem);
- }
- else
- {
- glVertexAttribPointer(sem, cc, type, true, stride, reinterpret_cast<void *>(offset));
- if(ARB_instanced_arrays)
- glVertexAttribDivisor(sem, divisor);
- glEnableVertexAttribArray(sem);
- }
- offset += get_attribute_size(*a);
- }
-
- if(!direct)
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-}
-