BlockGame/gl/VertexArray.cpp
2022-02-06 18:28:12 +01:00

31 lines
682 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(1, &handle);
Bind();
// specify syntax of my data
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) nullptr);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) 12);
glEnableVertexAttribArray(1);
}
unsigned VertexArray::getHandle() const {
return handle;
}