Add OpenGL backend core classes: Buffer, VertexArray
- Added OpenGLBuffer class for VBO/IBO management - Added OpenGLVertexArray class for VAO management - Updated CMakeLists.txt to include new source files
This commit is contained in:
44
tests/OpenGL/OpenGLVertexArray.h
Normal file
44
tests/OpenGL/OpenGLVertexArray.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
struct VertexAttribute {
|
||||
unsigned int index;
|
||||
int count;
|
||||
unsigned int type;
|
||||
bool normalized;
|
||||
size_t stride;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
class OpenGLVertexArray {
|
||||
public:
|
||||
OpenGLVertexArray();
|
||||
~OpenGLVertexArray();
|
||||
|
||||
bool Initialize();
|
||||
void AddVertexBuffer(unsigned int buffer, const VertexAttribute& attribute);
|
||||
void SetIndexBuffer(unsigned int buffer, unsigned int type);
|
||||
void Shutdown();
|
||||
|
||||
void Bind() const;
|
||||
void Unbind() const;
|
||||
|
||||
unsigned int GetID() const { return m_vao; }
|
||||
unsigned int GetIndexBuffer() const { return m_indexBuffer; }
|
||||
unsigned int GetIndexCount() const { return m_indexCount; }
|
||||
|
||||
private:
|
||||
unsigned int m_vao;
|
||||
unsigned int m_indexBuffer;
|
||||
unsigned int m_indexCount;
|
||||
int m_vertexBufferCount;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user