diff options
| author | hachem <im@hachem.wtf> | 2025-08-14 00:42:05 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-08-14 00:42:05 +0200 |
| commit | 0d8b874c0048ca088bb9e353a5f7c62e1f8cd0e8 (patch) | |
| tree | 2c0f3b13161489e4e91994882f8f2ed67a20bc0e /src/platform/opengl | |
| parent | 9671d5e54484b8bce261207d08ff15053ae24e48 (diff) | |
feat: custom memory managers and fix includes
Diffstat (limited to 'src/platform/opengl')
| -rw-r--r-- | src/platform/opengl/opengl_renderer_api.cpp | 8 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_renderer_api.h | 6 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_shader.cpp | 2 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_shader.h | 1 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_texture.cpp | 5 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_texture.h | 2 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_vertex_array.cpp | 5 | ||||
| -rw-r--r-- | src/platform/opengl/opengl_vertex_array.h | 15 |
8 files changed, 27 insertions, 17 deletions
diff --git a/src/platform/opengl/opengl_renderer_api.cpp b/src/platform/opengl/opengl_renderer_api.cpp index 1d41735..4542231 100644 --- a/src/platform/opengl/opengl_renderer_api.cpp +++ b/src/platform/opengl/opengl_renderer_api.cpp @@ -1,7 +1,7 @@ #include "opengl_renderer_api.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::draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, uint32_t index_count) + void OpenGLRendererAPI::draw_indexed(const Ref<VertexArray>& vertex_array, uint32_t index_count) { uint32_t count = index_count ? index_count : vertex_array->get_index_buffer()->get_count(); glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); diff --git a/src/platform/opengl/opengl_renderer_api.h b/src/platform/opengl/opengl_renderer_api.h index 15984d5..25accbb 100644 --- a/src/platform/opengl/opengl_renderer_api.h +++ b/src/platform/opengl/opengl_renderer_api.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 enable_depth_test() override; virtual void set_face_culling(bool enabled) override; - virtual void draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, + virtual void draw_indexed(const Ref<VertexArray>& vertex_array, uint32_t index_count = 0) override; }; }; diff --git a/src/platform/opengl/opengl_shader.cpp b/src/platform/opengl/opengl_shader.cpp index f4b99bc..3b0108e 100644 --- a/src/platform/opengl/opengl_shader.cpp +++ b/src/platform/opengl/opengl_shader.cpp @@ -1,6 +1,8 @@ #include "opengl_shader.h" + #include <glad/glad.h> #include <glm/gtc/type_ptr.hpp> + #include <fstream> #include <iostream> diff --git a/src/platform/opengl/opengl_shader.h b/src/platform/opengl/opengl_shader.h index 5870bda..6b1ceec 100644 --- a/src/platform/opengl/opengl_shader.h +++ b/src/platform/opengl/opengl_shader.h @@ -1,6 +1,7 @@ #pragma once #include "rendering/shader.h" + #include <unordered_map> #include <glm/glm.hpp> diff --git a/src/platform/opengl/opengl_texture.cpp b/src/platform/opengl/opengl_texture.cpp index 53ed06c..5d05fb4 100644 --- a/src/platform/opengl/opengl_texture.cpp +++ b/src/platform/opengl/opengl_texture.cpp @@ -1,5 +1,4 @@ #include "opengl_texture.h" -#include <iostream> namespace Donut { @@ -39,7 +38,7 @@ namespace Donut uint32_t white_pixel = 0xFFFFFFFF; glTextureSubImage2D(m_renderer_id, 0, 0, 0, m_width, m_height, m_data_format, GL_UNSIGNED_BYTE, &white_pixel); - 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() @@ -52,7 +51,7 @@ namespace Donut uint32_t bpp = m_data_format == 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/opengl_texture.h b/src/platform/opengl/opengl_texture.h index 41b352a..705d770 100644 --- a/src/platform/opengl/opengl_texture.h +++ b/src/platform/opengl/opengl_texture.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/opengl_vertex_array.cpp b/src/platform/opengl/opengl_vertex_array.cpp index c57479b..e2fb766 100644 --- a/src/platform/opengl/opengl_vertex_array.cpp +++ b/src/platform/opengl/opengl_vertex_array.cpp @@ -1,4 +1,5 @@ #include <glad/glad.h> + #include "opengl_vertex_array.h" #include "rendering/vertex_buffer.h" #include "rendering/index_buffer.h" @@ -25,7 +26,7 @@ namespace Donut glBindVertexArray(0); } - void OpenGLVertexArray::add_vertex_buffer(const std::shared_ptr<VertexBuffer>& vertex_buffer) + void OpenGLVertexArray::add_vertex_buffer(const Ref<VertexBuffer>& vertex_buffer) { glBindVertexArray(m_renderer_id); vertex_buffer->bind(); @@ -46,7 +47,7 @@ namespace Donut m_vertex_buffers.push_back(vertex_buffer); } - void OpenGLVertexArray::set_index_buffer(const std::shared_ptr<IndexBuffer>& index_buffer) + void OpenGLVertexArray::set_index_buffer(const Ref<IndexBuffer>& index_buffer) { glBindVertexArray(m_renderer_id); index_buffer->bind(); diff --git a/src/platform/opengl/opengl_vertex_array.h b/src/platform/opengl/opengl_vertex_array.h index d6986db..ff5cdd8 100644 --- a/src/platform/opengl/opengl_vertex_array.h +++ b/src/platform/opengl/opengl_vertex_array.h @@ -1,11 +1,12 @@ #pragma once +#include "core/memory.h" + #include "rendering/vertex_array.h" #include "rendering/vertex_buffer.h" #include "rendering/index_buffer.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 add_vertex_buffer(const std::shared_ptr<VertexBuffer>& vertex_buffer) override; - virtual void set_index_buffer(const std::shared_ptr<IndexBuffer>& index_buffer) override; + virtual void add_vertex_buffer(const Ref<VertexBuffer>& vertex_buffer) override; + virtual void set_index_buffer(const Ref<IndexBuffer>& index_buffer) override; - virtual const std::vector<std::shared_ptr<VertexBuffer>>& get_vertex_buffers() const override + virtual const std::vector<Ref<VertexBuffer>>& get_vertex_buffers() const override { return m_vertex_buffers; } - virtual const std::shared_ptr<IndexBuffer>& get_index_buffer() const override + virtual const Ref<IndexBuffer>& get_index_buffer() const override { return m_index_buffer; } private: uint32_t m_renderer_id; uint32_t m_vertex_buffer_index = 0; - std::vector<std::shared_ptr<VertexBuffer>> m_vertex_buffers; - std::shared_ptr<IndexBuffer> m_index_buffer; + std::vector<Ref<VertexBuffer>> m_vertex_buffers; + Ref<IndexBuffer> m_index_buffer; }; }; |
