From eb19c8a60359309a168c2b6ab46ec2baf8daf787 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Thu, 24 Feb 2022 18:20:29 -0500 Subject: [PATCH] Also remove all OpenGL specific custom rendering stuff. --- .../src/Platform/OpenGL/OpenGLBuffer.cpp | 52 ------------- Navigator/src/Platform/OpenGL/OpenGLBuffer.h | 40 ---------- .../src/Platform/OpenGL/OpenGLRendererAPI.cpp | 5 -- .../src/Platform/OpenGL/OpenGLRendererAPI.h | 1 - .../src/Platform/OpenGL/OpenGLVertexArray.cpp | 76 ------------------- .../src/Platform/OpenGL/OpenGLVertexArray.h | 31 -------- .../src/Platform/OpenGL/OpenGLWindow.cpp | 2 +- 7 files changed, 1 insertion(+), 206 deletions(-) delete mode 100644 Navigator/src/Platform/OpenGL/OpenGLBuffer.cpp delete mode 100644 Navigator/src/Platform/OpenGL/OpenGLBuffer.h delete mode 100644 Navigator/src/Platform/OpenGL/OpenGLVertexArray.cpp delete mode 100644 Navigator/src/Platform/OpenGL/OpenGLVertexArray.h diff --git a/Navigator/src/Platform/OpenGL/OpenGLBuffer.cpp b/Navigator/src/Platform/OpenGL/OpenGLBuffer.cpp deleted file mode 100644 index 8a1358c..0000000 --- a/Navigator/src/Platform/OpenGL/OpenGLBuffer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "OpenGLBuffer.h" - -#include "glad/glad.h" - -namespace Navigator { - - OpenGLVertexBuffer::OpenGLVertexBuffer(size_t size, float* arr) - { - glCreateBuffers(1, &m_renderID); - glBindBuffer(GL_ARRAY_BUFFER, m_renderID); - glBufferData(GL_ARRAY_BUFFER, size, arr, GL_STATIC_DRAW); - } - - OpenGLVertexBuffer::~OpenGLVertexBuffer() - { - glDeleteBuffers(1, &m_renderID); - } - - void OpenGLVertexBuffer::Bind() const - { - glBindBuffer(GL_ARRAY_BUFFER, m_renderID); - } - - void OpenGLVertexBuffer::Unbind() const - { - glBindBuffer(GL_ARRAY_BUFFER, 0); - } - - OpenGLIndexBuffer::OpenGLIndexBuffer(uint32_t count, uint32_t* arr) : - m_count(count) - { - glCreateBuffers(1, &m_renderID); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_renderID); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_count * sizeof(uint32_t), arr, GL_STATIC_DRAW); - } - - OpenGLIndexBuffer::~OpenGLIndexBuffer() - { - glDeleteBuffers(1, &m_renderID); - } - - void OpenGLIndexBuffer::Bind() const - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_renderID); - } - - void OpenGLIndexBuffer::Unbind() const - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - -} \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLBuffer.h b/Navigator/src/Platform/OpenGL/OpenGLBuffer.h deleted file mode 100644 index dbe0463..0000000 --- a/Navigator/src/Platform/OpenGL/OpenGLBuffer.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef OPENGL_BUFFER_H -#define OPENGL_BUFFER_H - -#include "Navigator/Renderer/Buffer.h" - -namespace Navigator { - - class NAV_API OpenGLVertexBuffer : public VertexBuffer - { - public: - OpenGLVertexBuffer(size_t size, float* arr); - ~OpenGLVertexBuffer(); - virtual void Bind() const override; - virtual void Unbind() const override; - - virtual void SetLayout(const BufferLayout& layout) override { m_layout = layout; } - virtual const BufferLayout& GetLayout() const override { return m_layout; } - - private: - uint32_t m_renderID; - BufferLayout m_layout; - }; - - class NAV_API OpenGLIndexBuffer : public IndexBuffer - { - public: - OpenGLIndexBuffer(uint32_t count, uint32_t* arr); - ~OpenGLIndexBuffer(); - virtual void Bind() const override; - virtual void Unbind() const override; - virtual uint32_t GetCount() const override { return m_count; } - - private: - uint32_t m_renderID; - uint32_t m_count; - }; - -} - -#endif \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp index a0a1b75..c0fd681 100644 --- a/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp +++ b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp @@ -13,9 +13,4 @@ namespace Navigator { { glClearColor(color_array[0], color_array[1], color_array[2], color_array[3]); } - - void OpenGLRendererAPI::DrawIndexed(const std::shared_ptr& array) - { - glDrawElements(GL_TRIANGLES, array->GetIndexBuffer()->GetCount(), GL_UNSIGNED_INT, nullptr); - } } \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h index d378aba..5f61d1d 100644 --- a/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h +++ b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h @@ -11,7 +11,6 @@ namespace Navigator { public: virtual void Clear() override; virtual void SetClearColor(const glm::vec4& color_array) override; - virtual void DrawIndexed(const std::shared_ptr& array) override; }; } diff --git a/Navigator/src/Platform/OpenGL/OpenGLVertexArray.cpp b/Navigator/src/Platform/OpenGL/OpenGLVertexArray.cpp deleted file mode 100644 index 6871417..0000000 --- a/Navigator/src/Platform/OpenGL/OpenGLVertexArray.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "OpenGLVertexArray.h" - -#include "glad/glad.h" - -namespace Navigator { - - static GLenum ConvertShaderDataTypeToGLenum(ShaderDataType type) - { - switch (type) - { - case Navigator::ShaderDataType::Float: return GL_FLOAT; - case Navigator::ShaderDataType::Float2: return GL_FLOAT; - case Navigator::ShaderDataType::Float3: return GL_FLOAT; - case Navigator::ShaderDataType::Float4: return GL_FLOAT; - case Navigator::ShaderDataType::Int: return GL_INT; - case Navigator::ShaderDataType::Int2: return GL_INT; - case Navigator::ShaderDataType::Int3: return GL_INT; - case Navigator::ShaderDataType::Int4: return GL_INT; - case Navigator::ShaderDataType::Mat3: return GL_FLOAT; - case Navigator::ShaderDataType::Mat4: return GL_FLOAT; - case Navigator::ShaderDataType::Bool: return GL_BOOL; - } - - NAV_ERROR("Unrecognized ShaderDataType at ConvertShaderDataTypeToGLenum!"); - return 0; - } - - OpenGLVertexArray::OpenGLVertexArray() - { - glCreateVertexArrays(1, &m_rendererID); - } - - OpenGLVertexArray::~OpenGLVertexArray() - { - glDeleteVertexArrays(1, &m_rendererID); - } - - void OpenGLVertexArray::Bind() const - { - glBindVertexArray(m_rendererID); - } - - void OpenGLVertexArray::Unbind() const - { - glBindVertexArray(0); - } - - void OpenGLVertexArray::AddVertexBuffer(const std::shared_ptr& buffer) - { - if(buffer->GetLayout().GetElements().size() == 0) - NAV_ERROR("VertexBuffer with no layout passed to VertexArray::AddVertexBuffer!"); - glBindVertexArray(m_rendererID); - buffer->Bind(); - - - uint32_t index = 0; - const auto& layout = buffer->GetLayout(); - for (const auto& element : layout) - { - glEnableVertexAttribArray(index); - glVertexAttribPointer(index, element.GetComponentCount(), ConvertShaderDataTypeToGLenum(element.type), element.normalized ? GL_TRUE : GL_FALSE, layout.GetStride(), (const void*)element.offset); - index++; - } - - m_vertexBuffers.push_back(buffer); - } - - void OpenGLVertexArray::SetIndexBuffer(const std::shared_ptr& buffer) - { - glBindVertexArray(m_rendererID); - buffer->Bind(); - - m_indexBuffer = buffer; - } - -} \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLVertexArray.h b/Navigator/src/Platform/OpenGL/OpenGLVertexArray.h deleted file mode 100644 index 6213f36..0000000 --- a/Navigator/src/Platform/OpenGL/OpenGLVertexArray.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef OPENGL_VERTEX_ARRAY -#define OPENGL_VERTEX_ARRAY - -#include "Navigator/Renderer/VertexArray.h" - -namespace Navigator { - - class NAV_API OpenGLVertexArray : public VertexArray - { - public: - OpenGLVertexArray(); - virtual ~OpenGLVertexArray(); - virtual void Bind() const override; - virtual void Unbind() const override; - - virtual void AddVertexBuffer(const std::shared_ptr& buffer) override; - virtual void SetIndexBuffer(const std::shared_ptr& buffer) override; - - inline virtual const std::vector>& GetVertexBuffers() const override { return m_vertexBuffers; } - inline virtual const std::shared_ptr& GetIndexBuffer() const { return m_indexBuffer; } - - private: - std::vector> m_vertexBuffers; - std::shared_ptr m_indexBuffer; - - uint32_t m_rendererID; - }; - -} - -#endif \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLWindow.cpp b/Navigator/src/Platform/OpenGL/OpenGLWindow.cpp index 3c25327..a752798 100644 --- a/Navigator/src/Platform/OpenGL/OpenGLWindow.cpp +++ b/Navigator/src/Platform/OpenGL/OpenGLWindow.cpp @@ -126,7 +126,7 @@ namespace Navigator { glfwSetScrollCallback(m_window, [](GLFWwindow* window, double xoffset, double yoffset) { Data& data = *(Data*) glfwGetWindowUserPointer(window); - MouseScrolledEvent event(xoffset, yoffset); + MouseScrolledEvent event((float)xoffset, (float)yoffset); data.event_callback_func(event); });