glGenBuffers(1, &vbo_triangle_colors); glBindBuffer(GL_ARRAY_BUFFER, vbo_triangle_colors); glBufferData(GL_ARRAY_BUFFER, sizeof(triangle_colors), triangle_colors, GL_STATIC_DRAW); char* attribute_name = "v_color"; auto attribute_v_color = glGetAttribLocation(program->getHandle(), attribute_name); if (attribute_v_color == -1) fprintf(stderr, "Could not bind attribute %s\n", attribute_name); glEnableVertexAttribArray(attribute_v_color); glBindBuffer(GL_ARRAY_BUFFER, vbo_triangle_colors); glVertexAttribPointer( attribute_v_color, // attribute 3, // number of elements per vertex, here (r,g,b) GL_FLOAT, // the type of each element GL_FALSE, // take our values as-is 0, // no extra data between each position 0 // offset of first element );