29 lines
618 B
C++
29 lines
618 B
C++
|
//
|
||
|
// 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;
|
||
|
}
|