Made multiple managers for individual pieces
Added UIManager that renders the UI inside the window
This commit is contained in:
38
BarinkEngine/graphics/GUI/GUIManager.cpp
Normal file
38
BarinkEngine/graphics/GUI/GUIManager.cpp
Normal 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());
|
||||
}
|
24
BarinkEngine/graphics/Renderer.cpp
Normal file
24
BarinkEngine/graphics/Renderer.cpp
Normal 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);
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user