Adding Perfomance monitor, Adding screenshot to README.md
This commit is contained in:
parent
08e1c3248b
commit
5006149c8d
BIN
PBR_Screenshot.png
(Stored with Git LFS)
Normal file
BIN
PBR_Screenshot.png
(Stored with Git LFS)
Normal file
Binary file not shown.
11
README.md
11
README.md
@ -1,5 +1,16 @@
|
|||||||
# Learn OpenGL
|
# Learn OpenGL
|
||||||
![OpenGL logo](https://www.opengl.org/sdk/inc/img/opengl_logo.png)
|
![OpenGL logo](https://www.opengl.org/sdk/inc/img/opengl_logo.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Screenshot :)
|
||||||
|
|
||||||
|
![PBR!!](PBR_Screenshot.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Resources Used
|
## Resources Used
|
||||||
[learnopengl.com](learnopengl.com) \
|
[learnopengl.com](learnopengl.com) \
|
||||||
[en.cppreference.com](en.cppreference.com)
|
[en.cppreference.com](en.cppreference.com)
|
12
src/main.cpp
12
src/main.cpp
@ -9,6 +9,7 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <backends/imgui_impl_glfw.h>
|
#include <backends/imgui_impl_glfw.h>
|
||||||
#include <backends/imgui_impl_opengl3.h>
|
#include <backends/imgui_impl_opengl3.h>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
@ -78,7 +79,7 @@ public:
|
|||||||
float currentFrame = glfwGetTime();
|
float currentFrame = glfwGetTime();
|
||||||
deltaTime = currentFrame - lastFrame;
|
deltaTime = currentFrame - lastFrame;
|
||||||
lastFrame = currentFrame;
|
lastFrame = currentFrame;
|
||||||
|
int fps = 1000 / (std::round(deltaTime/ 0.001) * 0.001);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
processInput(window.ptr());
|
processInput(window.ptr());
|
||||||
renderer.Render(scene);
|
renderer.Render(scene);
|
||||||
@ -89,6 +90,13 @@ public:
|
|||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
ImGui::ShowDemoWindow(nullptr);
|
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::Render();
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
@ -110,7 +118,7 @@ void processInput( GLFWwindow* window)
|
|||||||
if(glfwGetKey(window,GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
if(glfwGetKey(window,GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||||
glfwSetWindowShouldClose(window, true);
|
glfwSetWindowShouldClose(window, true);
|
||||||
|
|
||||||
const float CameraSpeed = 0.5f * deltaTime;
|
const float CameraSpeed = 0.8f * deltaTime;
|
||||||
if(glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
if(glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||||
scene.MainCamera.ProcessKeyboard(FORWARD, CameraSpeed);
|
scene.MainCamera.ProcessKeyboard(FORWARD, CameraSpeed);
|
||||||
if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||||
|
Loading…
Reference in New Issue
Block a user