Creado singleton GUI

parent 77ad0f12
Showing with 55 additions and 0 deletions
#include "gui.h"
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
namespace PAG {
GUI &GUI::getInstance() {
static GUI instance;
return instance;
}
void GUI::init(GLFWwindow *window) {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO &io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init();
}
void GUI::shutdown() {
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
GUI::GUI() {};
}
#pragma once
#include "glad/glad.h"
#include <GLFW/glfw3.h>
namespace PAG {
class GUI {
public:
static GUI &getInstance();
GUI(const GUI &) = delete;
void operator=(const GUI &) = delete;
void init(GLFWwindow *);
void shutdown();
private:
GUI();
};
};
......@@ -6,6 +6,7 @@
#include <GLFW/glfw3.h>
#include "renderer.h"
#include "gui.h"
// Helper que muestra un mensaje y cierra el programa
#define panic(message) { \
......@@ -107,6 +108,8 @@ int main() {
panic("GLAD initialization failed");
}
PAG::GUI::getInstance().init(window);
auto &renderer = PAG::Renderer::getInstance();
std::cout << renderer.getRendererName() << std::endl;
......@@ -135,6 +138,7 @@ int main() {
std::cout << "Finishing application pag prueba" << std::endl;
PAG::GUI::getInstance().shutdown();
glfwDestroyWindow(window);
glfwTerminate();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment