aboutsummaryrefslogtreecommitdiff
path: root/src/hud
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2020-07-07 06:40:50 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2020-07-07 06:40:50 +0200
commitaac94e911b0bab8db5cdb5efb8d4d8f2d4072610 (patch)
treea52a7a493076bba6e3ec5a7f9442bb3e77a5e16e /src/hud
parent29339928d7a05ca11786885643631206a978655e (diff)
Add code
Diffstat (limited to 'src/hud')
-rw-r--r--src/hud/hud.cpp32
-rw-r--r--src/hud/hud.hpp19
-rw-r--r--src/hud/hudcontext.cpp13
-rw-r--r--src/hud/hudcontext.hpp14
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;
+};
+
+