From a87e392d716e40849c6fba4103a12a3f2085e393 Mon Sep 17 00:00:00 2001 From: Huseyn Ismayilov Date: Sat, 24 Aug 2024 11:42:06 +0400 Subject: [PATCH] refactor(close #12): Clean Engine::Run function --- editor/src/main.cpp | 4 +++- engine/include/Renderer.h | 1 - engine/src/Engine.cpp | 3 --- engine/src/Renderer.cpp | 11 +++++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/editor/src/main.cpp b/editor/src/main.cpp index c176fc7..717f2b4 100644 --- a/editor/src/main.cpp +++ b/editor/src/main.cpp @@ -4,5 +4,7 @@ int main(int argc, char** argv) { Editor::Init(); - std::cout << argv << std::endl; + std::cout << "Argument count: " << argc << std::endl; + for(int i = 0; i < argc; i++) + std::cout << "Arguments: " << argv[i] << std::endl; } \ No newline at end of file diff --git a/engine/include/Renderer.h b/engine/include/Renderer.h index c90b549..14def04 100644 --- a/engine/include/Renderer.h +++ b/engine/include/Renderer.h @@ -28,7 +28,6 @@ public: static void Init(); static void Render(); - static void End(); static void Shutdown(); static RendererData GetData(); diff --git a/engine/src/Engine.cpp b/engine/src/Engine.cpp index 9b04373..8455d5d 100644 --- a/engine/src/Engine.cpp +++ b/engine/src/Engine.cpp @@ -20,10 +20,7 @@ Engine::~Engine() void Engine::Run() { while (!glfwWindowShouldClose(m_Window->GetWindow())) { - UI::Run(); Renderer::Render(); - UI::Render(*Renderer::GetData().m_FBO); - Renderer::End(); } } diff --git a/engine/src/Renderer.cpp b/engine/src/Renderer.cpp index 71d4343..aa726d3 100644 --- a/engine/src/Renderer.cpp +++ b/engine/src/Renderer.cpp @@ -71,8 +71,12 @@ void Renderer::SetupBuffers() } void Renderer::Render() { + glfwPollEvents(); glClearColor(0.0f, 0.1f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); + + UI::Run(); + s_Data.m_FBO->Bind(); s_Data.m_Shader->Use(); @@ -83,12 +87,10 @@ void Renderer::Render() { s_Data.m_VAO->Bind(); glDrawArrays(GL_TRIANGLES, 0, 3); FrameBuffer::Unbind(); -} -void Renderer::End() -{ + UI::Render(*s_Data.m_FBO); + glfwSwapBuffers(Engine::Get().GetWindow().GetWindow()); - glfwPollEvents(); } void Renderer::Shutdown() @@ -97,4 +99,5 @@ void Renderer::Shutdown() s_Data.m_VBO->Shutdown(); s_Data.m_FBO->Shutdown(); s_Data.m_Shader->Shutdown(); + s_Data.m_Texture->Shutdown(); }