Made multiple managers for individual pieces

Added UIManager that renders the UI inside the window
This commit is contained in:
2022-05-28 18:49:08 +02:00
parent dae8830e2b
commit 76c051e407
18 changed files with 358 additions and 197 deletions

View File

@ -0,0 +1,38 @@
#include "Graphics/GUI/GUIManager.h"
#include "imgui.h"
#include "backends/imgui_impl_opengl3.h"
#include <backends/imgui_impl_glfw.cpp>
GUIManager::GUIManager(BarinkWindow* window)
: currentwindow(window)
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
(void)io;
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true);
ImGui_ImplOpenGL3_Init("#version 440");
ImGui_ImplGlfw_NewFrame();
ImGui_ImplOpenGL3_NewFrame();
}
GUIManager::~GUIManager()
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void GUIManager::Render()
{
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}

View File

@ -0,0 +1,24 @@
#include "Graphics/Renderer.h"
BarinkEngine::Renderer::Renderer()
{
models = std::vector<Renderable*>();
}
BarinkEngine::Renderer::~Renderer()
{
// CleanUp!
}
void BarinkEngine::Renderer::Render()
{
for (auto model : models) {
model->Draw();
}
}
void BarinkEngine::Renderer::Submit(Renderable* model)
{
models.push_back(model);
}

View File

@ -1,12 +1,14 @@
#include "Graphics/Window.h"
#include <stdlib.h>
#include <stdio.h>
#include <GLFW/glfw3.h>
#include <spdlog/spdlog.h>
bool BarinkWindow::InitGLFW(){
if(!glfwInit())
{
// spdlog::error("Failed to initialise GLFW!");
spdlog::error("Failed to initialise GLFW!");
return false;
}
@ -23,7 +25,7 @@ Width(width), Height(height), FullScreen(false){
if( !window)
{
// spdlog::error("GLFW failed to create window!");
spdlog::error("GLFW failed to create window!");
glfwTerminate();
return;
}
@ -43,8 +45,6 @@ Width(width), Height(height), FullScreen(false){
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
}
@ -63,8 +63,7 @@ bool BarinkWindow::WindowShouldClose(){
}
void BarinkWindow::Poll()
{
{
glfwPollEvents();
}