36 lines
899 B
C++
36 lines
899 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;
|
|
}
|
|
|
|
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);
|
|
}
|