aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/OpenGL
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2025-08-14 00:42:05 +0200
committerhachem <im@hachem.wtf>2025-08-14 00:42:05 +0200
commite050dce79b67ae6386240567a994454711ab998d (patch)
tree4b5f55471d86b8ee80d531696e65dcea3b713e7a /src/Platform/OpenGL
parent2e246683df3b18e8e129adb0ada25be5f82f5b59 (diff)
[add]: Custom memory managers and fix includes
Diffstat (limited to 'src/Platform/OpenGL')
-rw-r--r--src/Platform/OpenGL/OpenGLRendererAPI.cpp8
-rw-r--r--src/Platform/OpenGL/OpenGLRendererAPI.h6
-rw-r--r--src/Platform/OpenGL/OpenGLShader.cpp2
-rw-r--r--src/Platform/OpenGL/OpenGLShader.h1
-rw-r--r--src/Platform/OpenGL/OpenGLTexture.cpp5
-rw-r--r--src/Platform/OpenGL/OpenGLTexture.h2
-rw-r--r--src/Platform/OpenGL/OpenGLVertexArray.cpp5
-rw-r--r--src/Platform/OpenGL/OpenGLVertexArray.h15
8 files changed, 27 insertions, 17 deletions
diff --git a/src/Platform/OpenGL/OpenGLRendererAPI.cpp b/src/Platform/OpenGL/OpenGLRendererAPI.cpp
index 7957fa0..3c49144 100644
--- a/src/Platform/OpenGL/OpenGLRendererAPI.cpp
+++ b/src/Platform/OpenGL/OpenGLRendererAPI.cpp
@@ -1,7 +1,7 @@
#include "OpenGLRendererAPI.h"
+
#include <glad/glad.h>
#include <GLFW/glfw3.h>
-#include <iostream>
namespace Donut
{
@@ -9,13 +9,13 @@ namespace Donut
{
if (!glfwGetCurrentContext())
{
- std::cout << "No OpenGL context is current! Cannot initialize GLAD." << std::endl;
+ DONUT_ERROR("No OpenGL context is current! Cannot initialize GLAD.");
return;
}
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
- std::cout << "Failed to initialize GLAD!" << std::endl;
+ DONUT_ERROR("Failed to initialize GLAD!");
return;
}
@@ -61,7 +61,7 @@ namespace Donut
glDisable(GL_CULL_FACE);
}
- void OpenGLRendererAPI::DrawIndexed(const std::shared_ptr<VertexArray>& vertexArray, uint32_t indexCount)
+ void OpenGLRendererAPI::DrawIndexed(const Ref<VertexArray>& vertexArray, uint32_t indexCount)
{
uint32_t count = indexCount ? indexCount : vertexArray->GetIndexBuffer()->GetCount();
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr);
diff --git a/src/Platform/OpenGL/OpenGLRendererAPI.h b/src/Platform/OpenGL/OpenGLRendererAPI.h
index 8211504..97e508b 100644
--- a/src/Platform/OpenGL/OpenGLRendererAPI.h
+++ b/src/Platform/OpenGL/OpenGLRendererAPI.h
@@ -1,6 +1,10 @@
#pragma once
+#include "Core/Memory.h"
+#include "Core/Log.h"
+
#include "Rendering/Renderer.h"
+
#include <glad/glad.h>
namespace Donut
@@ -17,7 +21,7 @@ namespace Donut
virtual void EnableDepthTest() override;
virtual void SetFaceCulling(bool enabled) override;
- virtual void DrawIndexed(const std::shared_ptr<VertexArray>& vertexArray,
+ virtual void DrawIndexed(const Ref<VertexArray>& vertexArray,
uint32_t indexCount = 0) override;
};
};
diff --git a/src/Platform/OpenGL/OpenGLShader.cpp b/src/Platform/OpenGL/OpenGLShader.cpp
index b24e158..b163cde 100644
--- a/src/Platform/OpenGL/OpenGLShader.cpp
+++ b/src/Platform/OpenGL/OpenGLShader.cpp
@@ -1,6 +1,8 @@
#include "OpenGLShader.h"
+
#include <glad/glad.h>
#include <glm/gtc/type_ptr.hpp>
+
#include <fstream>
#include <iostream>
diff --git a/src/Platform/OpenGL/OpenGLShader.h b/src/Platform/OpenGL/OpenGLShader.h
index cb7fec1..e9a7dc2 100644
--- a/src/Platform/OpenGL/OpenGLShader.h
+++ b/src/Platform/OpenGL/OpenGLShader.h
@@ -1,6 +1,7 @@
#pragma once
#include "Rendering/Shader.h"
+
#include <unordered_map>
#include <glm/glm.hpp>
diff --git a/src/Platform/OpenGL/OpenGLTexture.cpp b/src/Platform/OpenGL/OpenGLTexture.cpp
index 72e40ee..e12dea4 100644
--- a/src/Platform/OpenGL/OpenGLTexture.cpp
+++ b/src/Platform/OpenGL/OpenGLTexture.cpp
@@ -1,5 +1,4 @@
#include "OpenGLTexture.h"
-#include <iostream>
namespace Donut
{
@@ -40,7 +39,7 @@ namespace Donut
uint32_t whitePixel = 0xFFFFFFFF;
glTextureSubImage2D(m_RendererID, 0, 0, 0, m_Width, m_Height, m_DataFormat, GL_UNSIGNED_BYTE, &whitePixel);
- std::cout << "Created default texture (stb_image not available for loading: " << path << ")" << std::endl;
+ DONUT_INFO("Created default texture (stb_image not available for loading: ", path, ")");
}
OpenGLTexture2D::~OpenGLTexture2D()
@@ -53,7 +52,7 @@ namespace Donut
uint32_t bpp = m_DataFormat == GL_RGBA ? 4 : 3;
if (size != m_Width * m_Height * bpp)
{
- std::cout << "Data must be entire texture!" << std::endl;
+ DONUT_ERROR("Data must be entire texture!");
return;
}
diff --git a/src/Platform/OpenGL/OpenGLTexture.h b/src/Platform/OpenGL/OpenGLTexture.h
index 3c6c08a..1c3cb05 100644
--- a/src/Platform/OpenGL/OpenGLTexture.h
+++ b/src/Platform/OpenGL/OpenGLTexture.h
@@ -1,6 +1,8 @@
#pragma once
#include "Rendering/Texture.h"
+#include "Core/Log.h"
+
#include <glad/glad.h>
namespace Donut
diff --git a/src/Platform/OpenGL/OpenGLVertexArray.cpp b/src/Platform/OpenGL/OpenGLVertexArray.cpp
index c24441e..6019287 100644
--- a/src/Platform/OpenGL/OpenGLVertexArray.cpp
+++ b/src/Platform/OpenGL/OpenGLVertexArray.cpp
@@ -1,4 +1,5 @@
#include <glad/glad.h>
+
#include "OpenGLVertexArray.h"
#include "Rendering/VertexBuffer.h"
#include "Rendering/IndexBuffer.h"
@@ -25,7 +26,7 @@ namespace Donut
glBindVertexArray(0);
}
- void OpenGLVertexArray::AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer)
+ void OpenGLVertexArray::AddVertexBuffer(const Ref<VertexBuffer>& vertexBuffer)
{
glBindVertexArray(m_RendererID);
vertexBuffer->Bind();
@@ -46,7 +47,7 @@ namespace Donut
m_VertexBuffers.push_back(vertexBuffer);
}
- void OpenGLVertexArray::SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer)
+ void OpenGLVertexArray::SetIndexBuffer(const Ref<IndexBuffer>& indexBuffer)
{
glBindVertexArray(m_RendererID);
indexBuffer->Bind();
diff --git a/src/Platform/OpenGL/OpenGLVertexArray.h b/src/Platform/OpenGL/OpenGLVertexArray.h
index 545f02c..b6ae82f 100644
--- a/src/Platform/OpenGL/OpenGLVertexArray.h
+++ b/src/Platform/OpenGL/OpenGLVertexArray.h
@@ -1,11 +1,12 @@
#pragma once
+#include "Core/Memory.h"
+
#include "Rendering/VertexArray.h"
#include "Rendering/VertexBuffer.h"
#include "Rendering/IndexBuffer.h"
#include <vector>
-#include <memory>
namespace Donut
{
@@ -19,22 +20,22 @@ namespace Donut
virtual void Bind() const override;
virtual void Unbind() const override;
- virtual void AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer) override;
- virtual void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer) override;
+ virtual void AddVertexBuffer(const Ref<VertexBuffer>& vertexBuffer) override;
+ virtual void SetIndexBuffer(const Ref<IndexBuffer>& indexBuffer) override;
- virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const override
+ virtual const std::vector<Ref<VertexBuffer>>& GetVertexBuffers() const override
{
return m_VertexBuffers;
}
- virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const override
+ virtual const Ref<IndexBuffer>& GetIndexBuffer() const override
{
return m_IndexBuffer;
}
private:
uint32_t m_RendererID;
uint32_t m_VertexBufferIndex = 0;
- std::vector<std::shared_ptr<VertexBuffer>> m_VertexBuffers;
- std::shared_ptr<IndexBuffer> m_IndexBuffer;
+ std::vector<Ref<VertexBuffer>> m_VertexBuffers;
+ Ref<IndexBuffer> m_IndexBuffer;
};
};