Add ImGui and refactor

This commit is contained in:
Jack Christensen 2024-08-11 14:52:38 -04:00
parent b416f8da27
commit 4261ce59f7
2 changed files with 32 additions and 10 deletions

View File

@ -2,6 +2,9 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <iostream> #include <iostream>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include "scene.h" #include "scene.h"
int main(){ int main(){
@ -24,13 +27,26 @@ int main(){
return -1; return -1;
} }
Scene::Init();
//Init ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 150");
while (!glfwWindowShouldClose(window)) { while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
Scene::Idle(); Scene::Idle();
glfwSwapBuffers(window); Scene::Display(window);
glfwPollEvents(); glfwPollEvents();
} }
// Cleanup ImGui
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window); glfwDestroyWindow(window);
glfwTerminate(); glfwTerminate();
return 0; return 0;

View File

@ -12,10 +12,16 @@ void Scene::DrawGUI(GLFWwindow* window){
} }
void Scene::Display(GLFWwindow* window) { void Scene::Display(GLFWwindow* window) {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
} }
void Scene::Idle() { void Scene::Idle() {
} }
void Scene::Init() { void Scene::Init() {
glewInit();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
} }