Added own shaders

This commit is contained in:
2026-04-13 00:51:32 +02:00
parent c964fcc984
commit 64b27a6b84
9 changed files with 219 additions and 10 deletions

34
include/VertexBuffer.hpp Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include <GL/glew.h>
#include "defines.hpp"
struct VertexBuffer {
VertexBuffer(void* data, uint32 numVertices) {
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &bufferId);
glBindBuffer(GL_ARRAY_BUFFER, bufferId);
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Vertex), data, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), offsetof(struct Vertex,x));
glBindVertexArray(0);
};
virtual ~VertexBuffer() {
glDeleteBuffers(1, &bufferId);
}
void bind() {
glBindVertexArray(vao);
}
void unbind() {
glBindVertexArray(0);
}
private:
GLuint bufferId;
GLuint vao;
};