BlockGame/gl/VertexArray.cpp

36 lines
899 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();
2022-02-06 21:53:29 +00:00
// // 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);
2022-02-05 20:44:31 +00:00
}
unsigned VertexArray::getHandle() const {
return handle;
}
2022-02-06 21:53:29 +00:00
void VertexArray::add(int index, int size, int stride, int pos) {
glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, stride * sizeof(float), (void *) pos);
glEnableVertexAttribArray(index);
}