aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/OpenGL
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/OpenGL')
-rw-r--r--src/Platform/OpenGL/OpenGLRendererAPI.cpp16
-rw-r--r--src/Platform/OpenGL/OpenGLRendererAPI.h3
-rw-r--r--src/Platform/OpenGL/OpenGLUniformBuffer.cpp29
-rw-r--r--src/Platform/OpenGL/OpenGLUniformBuffer.h22
4 files changed, 70 insertions, 0 deletions
diff --git a/src/Platform/OpenGL/OpenGLRendererAPI.cpp b/src/Platform/OpenGL/OpenGLRendererAPI.cpp
index 3c49144..d181203 100644
--- a/src/Platform/OpenGL/OpenGLRendererAPI.cpp
+++ b/src/Platform/OpenGL/OpenGLRendererAPI.cpp
@@ -49,6 +49,11 @@ namespace Donut
glEnable(GL_DEPTH_TEST);
}
+ void OpenGLRendererAPI::DisableDepthTest()
+ {
+ glDisable(GL_DEPTH_TEST);
+ }
+
void OpenGLRendererAPI::SetFaceCulling(bool enabled)
{
if (enabled)
@@ -61,6 +66,17 @@ namespace Donut
glDisable(GL_CULL_FACE);
}
+ void OpenGLRendererAPI::EnableBlending()
+ {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+
+ void OpenGLRendererAPI::DisableBlending()
+ {
+ glDisable(GL_BLEND);
+ }
+
void OpenGLRendererAPI::DrawIndexed(const Ref<VertexArray>& vertexArray, uint32_t indexCount)
{
uint32_t count = indexCount ? indexCount : vertexArray->GetIndexBuffer()->GetCount();
diff --git a/src/Platform/OpenGL/OpenGLRendererAPI.h b/src/Platform/OpenGL/OpenGLRendererAPI.h
index 97e508b..f6b9fb4 100644
--- a/src/Platform/OpenGL/OpenGLRendererAPI.h
+++ b/src/Platform/OpenGL/OpenGLRendererAPI.h
@@ -19,7 +19,10 @@ namespace Donut
virtual void SetClearColor(const glm::vec4& color) override;
virtual void Clear() override;
virtual void EnableDepthTest() override;
+ virtual void DisableDepthTest() override;
virtual void SetFaceCulling(bool enabled) override;
+ virtual void EnableBlending() override;
+ virtual void DisableBlending() override;
virtual void DrawIndexed(const Ref<VertexArray>& vertexArray,
uint32_t indexCount = 0) override;
diff --git a/src/Platform/OpenGL/OpenGLUniformBuffer.cpp b/src/Platform/OpenGL/OpenGLUniformBuffer.cpp
new file mode 100644
index 0000000..631b863
--- /dev/null
+++ b/src/Platform/OpenGL/OpenGLUniformBuffer.cpp
@@ -0,0 +1,29 @@
+#include "OpenGLUniformBuffer.h"
+
+namespace Donut
+{
+ OpenGLUniformBuffer::OpenGLUniformBuffer(uint32_t size, uint32_t binding)
+ : m_Size(size), m_Binding(binding)
+ {
+ glGenBuffers(1, &m_RendererID);
+ glBindBuffer(GL_UNIFORM_BUFFER, m_RendererID);
+ glBufferData(GL_UNIFORM_BUFFER, size, nullptr, GL_DYNAMIC_DRAW);
+ glBindBufferBase(GL_UNIFORM_BUFFER, binding, m_RendererID);
+ }
+
+ OpenGLUniformBuffer::~OpenGLUniformBuffer()
+ {
+ glDeleteBuffers(1, &m_RendererID);
+ }
+
+ void OpenGLUniformBuffer::SetData(const void* data, uint32_t size, uint32_t offset)
+ {
+ glBindBuffer(GL_UNIFORM_BUFFER, m_RendererID);
+ glBufferSubData(GL_UNIFORM_BUFFER, offset, size, data);
+ }
+
+ void OpenGLUniformBuffer::Bind(uint32_t binding)
+ {
+ glBindBufferBase(GL_UNIFORM_BUFFER, binding, m_RendererID);
+ }
+};
diff --git a/src/Platform/OpenGL/OpenGLUniformBuffer.h b/src/Platform/OpenGL/OpenGLUniformBuffer.h
new file mode 100644
index 0000000..6e7fac1
--- /dev/null
+++ b/src/Platform/OpenGL/OpenGLUniformBuffer.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "Rendering/UniformBuffer.h"
+#include <glad/glad.h>
+
+namespace Donut
+{
+ class OpenGLUniformBuffer : public UniformBuffer
+ {
+ public:
+ OpenGLUniformBuffer(uint32_t size, uint32_t binding);
+ virtual ~OpenGLUniformBuffer();
+
+ virtual void SetData(const void* data, uint32_t size, uint32_t offset = 0) override;
+ virtual void Bind(uint32_t binding) override;
+
+ private:
+ uint32_t m_RendererID = 0;
+ uint32_t m_Size = 0;
+ uint32_t m_Binding = 0;
+ };
+};