added uniforms

This commit is contained in:
2026-04-15 23:54:09 +02:00
parent ee06b834b9
commit 291f774a95
6 changed files with 126 additions and 8 deletions

34
include/IndexBuffer.hpp Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include <GL/glew.h>
#include "defines.hpp"
struct IndexBuffer {
IndexBuffer(void* data, uint32 numIndices, uint8 elementSize) {
glGenBuffers(1, &bufferId);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferId);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices*elementSize, data, GL_STATIC_DRAW);
// POSITION
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(Vertex,x));
// COLOR
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(Vertex,r));
glBindVertexArray(0);
};
virtual ~IndexBuffer() {
glDeleteBuffers(1, &bufferId);
}
void bind() {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferId);
}
void unbind() {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
private:
GLuint bufferId;
};

View File

@@ -10,6 +10,8 @@ struct Shader {
void bind();
void unbind();
GLuint getShaderId();
private:
GLuint compile(std::string shaderSource, GLenum shaderType);
std::string parse(const char* filename);