diff options
Diffstat (limited to 'src/hud')
| -rw-r--r-- | src/hud/hud.cpp | 32 | ||||
| -rw-r--r-- | src/hud/hud.hpp | 19 | ||||
| -rw-r--r-- | src/hud/hudcontext.cpp | 13 | ||||
| -rw-r--r-- | src/hud/hudcontext.hpp | 14 |
4 files changed, 78 insertions, 0 deletions
diff --git a/src/hud/hud.cpp b/src/hud/hud.cpp new file mode 100644 index 0000000..fb9f65e --- /dev/null +++ b/src/hud/hud.cpp @@ -0,0 +1,32 @@ +#include "hud.hpp" + +HUD::HUD(GLFWwindow* window): + m_ImGuiContext(ImGui::CreateContext()), + m_POpen(true) +{ + ImGui::SetCurrentContext(m_ImGuiContext); + ImGui_ImplGlfw_InitForOpenGL(window, true); + ImGui_ImplOpenGL3_Init("#version 330"); + m_Context=new HUDContext(); +} + +HUD::~HUD(){ + delete(m_Context); +} + +void HUD::Render(){ + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + + ImGui::SetNextWindowPos(ImVec2(0,0)); + ImGui::SetNextWindowBgAlpha(0.6f); + ImGui::Begin("HUD",&m_POpen,ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav); + ImGui::Text("FPS: %d",m_Context->fps); + ImGui::Text("Current Shader: %s",m_Context->current_shader.c_str()); + ImGui::Text("Simulation Time: %llds",m_Context->time); + ImGui::End(); + + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); +} diff --git a/src/hud/hud.hpp b/src/hud/hud.hpp new file mode 100644 index 0000000..fed7f42 --- /dev/null +++ b/src/hud/hud.hpp @@ -0,0 +1,19 @@ +#pragma once +#include <GL/glew.h> +#include <GLFW/glfw3.h> +#include "vendors/imgui/imgui.h" +#include "vendors/imgui/imgui_impl_opengl3.h" +#include "vendors/imgui/imgui_impl_glfw.h" +#include "hudcontext.hpp" + +class HUD { +private: + ImGuiContext* m_ImGuiContext; + bool m_POpen; +public: + HUDContext *m_Context; + + HUD(GLFWwindow* window); + ~HUD(); + void Render(); +}; diff --git a/src/hud/hudcontext.cpp b/src/hud/hudcontext.cpp new file mode 100644 index 0000000..fffd5a0 --- /dev/null +++ b/src/hud/hudcontext.cpp @@ -0,0 +1,13 @@ +#include "hudcontext.hpp" + + +HUDContext::HUDContext(): + fps(0), + fps_frame_counter(0), + current_shader("Unknown"), + time(0) +{ + +} + + diff --git a/src/hud/hudcontext.hpp b/src/hud/hudcontext.hpp new file mode 100644 index 0000000..5c1b8b8 --- /dev/null +++ b/src/hud/hudcontext.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include <string> + +class HUDContext{ +public: + HUDContext(); + short fps; + int fps_frame_counter; + std::string current_shader; + long long time; +}; + + |
