terravisor/source/main.cpp

54 lines
1.1 KiB
C++
Raw Normal View History

2024-08-10 19:12:21 -04:00
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
2024-08-11 14:52:38 -04:00
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
2024-08-10 19:12:21 -04:00
#include "scene.h"
int main(){
2024-08-11 14:52:38 -04:00
if (!glfwInit()) {
2024-08-10 19:12:21 -04:00
std::cerr << "Failed to initialize GLFW" << std::endl;
return -1;
}
GLFWwindow* window = glfwCreateWindow(800, 600, "TerraVisor", nullptr, nullptr);
2024-08-11 14:52:38 -04:00
if(!window) {
2024-08-10 19:12:21 -04:00
std::cerr << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
2024-08-11 14:52:38 -04:00
if(glewInit() != GLEW_OK) {
2024-08-10 19:12:21 -04:00
std::cerr << "Failed to initialize GLEW" << std::endl;
return -1;
}
2024-08-11 14:52:38 -04:00
Scene::Init();
//Init ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 150");
2024-08-10 19:12:21 -04:00
2024-08-11 14:52:38 -04:00
while (!glfwWindowShouldClose(window)) {
2024-08-10 19:12:21 -04:00
Scene::Idle();
2024-08-11 14:52:38 -04:00
Scene::Display(window);
2024-08-10 19:12:21 -04:00
glfwPollEvents();
}
2024-08-11 14:52:38 -04:00
// Cleanup ImGui
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
2024-08-10 19:12:21 -04:00
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}