From a6655eebe2a69ee427264bd43df5747851ed96df Mon Sep 17 00:00:00 2001 From: hachem Date: Fri, 15 Aug 2025 03:18:29 +0200 Subject: feat: complete first geodesic 3D raytracing --- src/platform/opengl/opengl_renderer_api.cpp | 23 +++++++++++++++++++++++ src/platform/opengl/opengl_renderer_api.h | 10 ++++++++++ src/platform/opengl/opengl_uniform_buffer.h | 7 +++---- 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src/platform/opengl') diff --git a/src/platform/opengl/opengl_renderer_api.cpp b/src/platform/opengl/opengl_renderer_api.cpp index 628c0af..bfb79ac 100644 --- a/src/platform/opengl/opengl_renderer_api.cpp +++ b/src/platform/opengl/opengl_renderer_api.cpp @@ -83,4 +83,27 @@ namespace Donut glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); glBindTexture(GL_TEXTURE_2D, 0); } + + void OpenGLRendererAPI::draw_arrays(uint32_t vertex_count, uint32_t first) + { + glDrawArrays(GL_TRIANGLES, first, vertex_count); + } + + void OpenGLRendererAPI::draw_lines(const Ref& vertex_array, uint32_t index_count) + { + uint32_t count = index_count ? index_count : vertex_array->get_index_buffer()->get_count(); + glDrawElements(GL_LINES, count, GL_UNSIGNED_INT, nullptr); + } + + void OpenGLRendererAPI::bind_texture(uint32_t texture_id, uint32_t slot) + { + glActiveTexture(GL_TEXTURE0 + slot); + glBindTexture(GL_TEXTURE_2D, texture_id); + } + + void OpenGLRendererAPI::bind_image_texture(uint32_t texture_id, uint32_t slot, bool read_only) + { + glBindImageTexture(slot, texture_id, 0, GL_FALSE, 0, + read_only ? GL_READ_ONLY : GL_WRITE_ONLY, GL_RGBA8); + } }; diff --git a/src/platform/opengl/opengl_renderer_api.h b/src/platform/opengl/opengl_renderer_api.h index fd446c6..45e6a7b 100644 --- a/src/platform/opengl/opengl_renderer_api.h +++ b/src/platform/opengl/opengl_renderer_api.h @@ -26,5 +26,15 @@ namespace Donut virtual void draw_indexed(const Ref& vertex_array, uint32_t index_count = 0) override; + + virtual void draw_arrays(uint32_t vertex_count, + uint32_t first = 0) override; + virtual void draw_lines(const Ref& vertex_array, + uint32_t index_count = 0) override; + virtual void bind_texture(uint32_t texture_id, + uint32_t slot = 0) override; + virtual void bind_image_texture(uint32_t texture_id, + uint32_t slot = 0, + bool read_only = false) override; }; }; diff --git a/src/platform/opengl/opengl_uniform_buffer.h b/src/platform/opengl/opengl_uniform_buffer.h index 2a9131f..ae99a56 100644 --- a/src/platform/opengl/opengl_uniform_buffer.h +++ b/src/platform/opengl/opengl_uniform_buffer.h @@ -12,11 +12,10 @@ namespace Donut virtual ~OpenGLUniformBuffer(); virtual void set_data(const void* data, uint32_t size, uint32_t offset = 0) override; - virtual void bind(uint32_t binding) override; - + virtual void bind(uint32_t binding) override; private: uint32_t m_renderer_id = 0; - uint32_t m_size = 0; - uint32_t m_binding = 0; + uint32_t m_size = 0; + uint32_t m_binding = 0; }; }; -- cgit v1.3