Skip to content

Commit

Permalink
refactor(close #12): Clean Engine::Run function
Browse files Browse the repository at this point in the history
  • Loading branch information
coderloff committed Aug 24, 2024
1 parent 9a866d1 commit a87e392
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion editor/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion engine/include/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Renderer

static void Init();
static void Render();
static void End();
static void Shutdown();

static RendererData GetData();
Expand Down
3 changes: 0 additions & 3 deletions engine/src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
11 changes: 7 additions & 4 deletions engine/src/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()
Expand All @@ -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();
}

0 comments on commit a87e392

Please sign in to comment.