From 5006149c8d1f0d240180e20c2063f07dac1d4b57 Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Sat, 20 May 2023 22:08:43 +0200 Subject: [PATCH] Adding Perfomance monitor, Adding screenshot to README.md --- PBR_Screenshot.png | 3 +++ README.md | 11 +++++++++++ src/main.cpp | 12 ++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 PBR_Screenshot.png diff --git a/PBR_Screenshot.png b/PBR_Screenshot.png new file mode 100644 index 0000000..aea36df --- /dev/null +++ b/PBR_Screenshot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c32f73e0b0eae9eae8b2435e93405f11724dd15f3297a30e160025f87a15d49 +size 819586 diff --git a/README.md b/README.md index 8903d72..00fba48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ # Learn OpenGL ![OpenGL logo](https://www.opengl.org/sdk/inc/img/opengl_logo.png) + + + + +## Screenshot :) + +![PBR!!](PBR_Screenshot.png) + + + + ## Resources Used [learnopengl.com](learnopengl.com) \ [en.cppreference.com](en.cppreference.com) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index aa0dd85..d2e147b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #define STB_IMAGE_IMPLEMENTATION #include @@ -78,7 +79,7 @@ public: float currentFrame = glfwGetTime(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; - + int fps = 1000 / (std::round(deltaTime/ 0.001) * 0.001); glfwPollEvents(); processInput(window.ptr()); renderer.Render(scene); @@ -89,6 +90,13 @@ public: ImGui::NewFrame(); ImGui::ShowDemoWindow(nullptr); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.6f)); + ImGui::Begin("##Performance"); + ImGui::Text("Frame time: %5.3f", deltaTime); + ImGui::Text("FPS: %d", fps ); + ImGui::End(); + ImGui::PopStyleColor(); + ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); @@ -110,7 +118,7 @@ void processInput( GLFWwindow* window) if(glfwGetKey(window,GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); - const float CameraSpeed = 0.5f * deltaTime; + const float CameraSpeed = 0.8f * deltaTime; if(glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) scene.MainCamera.ProcessKeyboard(FORWARD, CameraSpeed); if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)