BlockGame/gl/VertexArray.cpp

29 lines
685 B
C++

//
// Created by lukas on 04.02.22.
//
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include "VertexArray.h"
void VertexArray::Bind() const {
glBindVertexArray(handle);
}
VertexArray::VertexArray(const VertexBuffer& buff) {
buff.Bind();
// generate new vertex array object
glGenVertexArrays(2, &handle);
Bind();
// specify syntax of my data
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) nullptr);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) nullptr);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
}
unsigned VertexArray::getHandle() const {
return handle;
}