-Model::Model() noexcept
-: va(0)
-, handle{}
-, count(0) {
- glGenVertexArrays(1, &va);
- glGenBuffers(ATTRIB_COUNT, handle);
-}
-
-Model::~Model() noexcept {
- glDeleteBuffers(ATTRIB_COUNT, handle);
- glDeleteVertexArrays(1, &va);
-}
-
-Model::Model(Model &&other) noexcept
-: va(other.va)
-, count(other.count) {
- other.va = 0;
- for (int i = 0; i < ATTRIB_COUNT; ++i) {
- handle[i] = other.handle[i];
- other.handle[i] = 0;
- }
-}
-
-Model &Model::operator =(Model &&other) noexcept {
- std::swap(va, other.va);
- for (int i = 0; i < ATTRIB_COUNT; ++i) {
- std::swap(handle[i], other.handle[i]);
- }
- count = other.count;
- return *this;
-}
-
-void Model::Update(const Buffer &buf) noexcept {
- glBindVertexArray(va);
- glBindBuffer(GL_ARRAY_BUFFER, handle[ATTRIB_VERTEX]);
- glBufferData(GL_ARRAY_BUFFER, buf.vertices.size() * sizeof(glm::vec3), buf.vertices.data(), GL_STATIC_DRAW);
- glEnableVertexAttribArray(ATTRIB_VERTEX);
- glVertexAttribPointer(
- ATTRIB_VERTEX, // location (for shader)
- 3, // size
- GL_FLOAT, // type
- GL_FALSE, // normalized
- 0, // stride
- nullptr // offset
- );
-