buffers
This commit is contained in:
57
inc/engine/buffers.hpp
Normal file
57
inc/engine/buffers.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#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
|
||||
@@ -4,6 +4,8 @@
|
||||
// Includes
|
||||
#include <SDL3/SDL_opengl.h>
|
||||
#include "engine/sdl.hpp"
|
||||
#include "engine/buffers.hpp"
|
||||
#include "engine/shaders.hpp"
|
||||
|
||||
// OpenGL Context Class
|
||||
class OpenGLContext {
|
||||
|
||||
Reference in New Issue
Block a user