BlockGame/gl/VertexArray.cpp

31 lines
682 B
C++
Raw Normal View History

2022-02-05 20:44:31 +00:00
//
// 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
2022-02-06 17:28:12 +00:00
glGenVertexArrays(1, &handle);
2022-02-05 20:44:31 +00:00
Bind();
// specify syntax of my data
2022-02-06 13:47:33 +00:00
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) nullptr);
2022-02-05 20:44:31 +00:00
glEnableVertexAttribArray(0);
2022-02-06 17:28:12 +00:00
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) 12);
2022-02-06 13:47:33 +00:00
glEnableVertexAttribArray(1);
2022-02-05 20:44:31 +00:00
}
unsigned VertexArray::getHandle() const {
return handle;
}