Files
untitled-game/inc/engine/buffers.hpp
2025-11-24 12:54:13 +00:00

57 lines
1.3 KiB
C++

#ifndef BUFFERS_HPP
#define BUFFERS_HPP
#define GL_GLEXT_PROTOTYPES
#include <SDL3/SDL_opengl.h>
#include <cstddef>
#include <memory>
// Vertex Buffer Class
class VertexBuffer {
public:
VertexBuffer();
~VertexBuffer();
void bind() const;
void setData(const void* data, GLsizeiptr size);
void setAttributePointer(GLuint index, std::size_t size, GLenum type, bool normalized, std::size_t stride, std::size_t pointer);
private:
GLuint bufferID;
};
// Element Buffer Class
class ElementBuffer {
public:
ElementBuffer();
~ElementBuffer();
void bind() const;
void setData(const void* data, GLsizeiptr size);
void draw() const;
private:
GLuint bufferID;
std::size_t elementCount;
GLenum drawMode;
};
// Vertex Array Object Class
class VertexArrayObject {
public:
VertexArrayObject();
~VertexArrayObject();
void bind() const;
void draw() const;
void bufferVertexData(const void* data, GLsizeiptr size);
void bufferElementData(const void* data, GLsizeiptr size);
void setAttributePointer(GLuint index, std::size_t size, GLenum type, bool normalized, std::size_t stride, std::size_t pointer);
private:
GLuint arrayID;
std::unique_ptr<VertexBuffer> vertexBuffer;
std::unique_ptr<ElementBuffer> elementBuffer;
};
#endif