#ifndef GLYPH_ATTR_H
#define GLYPH_ATTR_H

struct glyph_attr {
	GLint size;
	GLenum type;
	GLboolean norm;
	GLsizei stride;
	size_t offset;
};

void glyph_attr_declare(const struct glyph_attr *attrs, size_t size);

#if defined(GLYPH_ATTR_IMP) || defined(IMP)

void
glyph_attr_declare(const struct glyph_attr *attrs, size_t size)
{
	for ( size_t i = 0; i < size; ++i ) {
		struct glyph_attr ga = attrs[i];
		glEnableVertexAttribArray((uint32_t) i);
		switch ( ga.type ) {
		case GL_FLOAT: {
			glVertexAttribPointer((uint32_t) i,
					      ga.size, ga.type,
					      ga.norm, ga.stride,
					      (void*)ga.offset);
		} break;
		case GL_INT: {
			glVertexAttribIPointer((uint32_t) i,
					       ga.size, ga.type,
					       ga.stride,
					       (void*)ga.offset);
		} break;
		}
		glVertexAttribDivisor((uint32_t) i, 1);
	}
}

#endif /* defined(GLYPH_ATTR_IMP) || defined(IMP) */

#endif
