BlockGame/gl/IndexBuffer.cpp

29 lines
618 B
C++
Raw Permalink Normal View History

2022-02-05 20:44:31 +00:00
//
// Created by lukas on 03.02.22.
//
#include "IndexBuffer.h"
#include <GL/gl.h>
IndexBuffer::IndexBuffer(const unsigned *data, unsigned count): count(count) {
glGenBuffers(1, &handle);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handle);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned) * count , data, GL_STATIC_DRAW);
}
IndexBuffer::~IndexBuffer() {
glDeleteBuffers(1, &handle);
}
void IndexBuffer::Bind() const {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handle);
}
void IndexBuffer::UnBind() const {
glBindVertexArray(0);
}
unsigned IndexBuffer::getcount() const {
return count;
}