-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d90fec
commit 974fe04
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "OpenGLBuffer.h" | ||
|
||
#include <glad/glad.h> | ||
|
||
namespace Arcane | ||
{ | ||
//////////////////////////////////////////////////////// | ||
//// Vertex Buffer | ||
//////////////////////////////////////////////////////// | ||
OpenGLVertexBuffer::OpenGLVertexBuffer(void* data, uint32_t size) | ||
{ | ||
glGenBuffers(1, &m_VBO); | ||
glBindBuffer(GL_ARRAY_BUFFER, m_VBO); | ||
glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW); | ||
glBindBuffer(GL_ARRAY_BUFFER, 0); | ||
} | ||
|
||
void OpenGLVertexBuffer::AddIndexBuffer(IndexBuffer* _indexBuffer) | ||
{ | ||
m_IndexBuffer = _indexBuffer; | ||
} | ||
|
||
IndexBuffer* OpenGLVertexBuffer::GetIndexBuffer() | ||
{ | ||
return m_IndexBuffer; | ||
} | ||
|
||
//////////////////////////////////////////////////////// | ||
//// Index Buffer | ||
//////////////////////////////////////////////////////// | ||
OpenGLIndexBuffer::OpenGLIndexBuffer(void* data, uint32_t count) | ||
{ | ||
m_Count = count; | ||
|
||
glGenBuffers(1, &m_EBO); | ||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_EBO); | ||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * count, data, GL_STATIC_DRAW); | ||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | ||
} | ||
|
||
uint32_t OpenGLIndexBuffer::GetCount() | ||
{ | ||
return m_Count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include "Arcane/Renderer/Buffer.h" | ||
|
||
namespace Arcane | ||
{ | ||
//////////////////////////////////////////////////////// | ||
//// Vertex Buffer | ||
//////////////////////////////////////////////////////// | ||
class OpenGLVertexBuffer : public VertexBuffer | ||
{ | ||
public: | ||
OpenGLVertexBuffer(void* data, uint32_t size); | ||
|
||
void AddIndexBuffer(IndexBuffer* _indexBuffer) override; | ||
IndexBuffer* GetIndexBuffer() override; | ||
private: | ||
IndexBuffer* m_IndexBuffer; | ||
uint32_t m_VBO; | ||
}; | ||
|
||
//////////////////////////////////////////////////////// | ||
//// Index Buffer | ||
//////////////////////////////////////////////////////// | ||
class OpenGLIndexBuffer : public IndexBuffer | ||
{ | ||
public: | ||
OpenGLIndexBuffer(void* data, uint32_t count); | ||
|
||
uint32_t GetCount(); | ||
private: | ||
uint32_t m_EBO; | ||
uint32_t m_Count; | ||
}; | ||
|
||
} |