2024-08-10 19:12:21 -04:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
2024-08-11 21:20:17 -04:00
|
|
|
#include <imgui.h>
|
|
|
|
#include <imgui_impl_glfw.h>
|
|
|
|
#include <imgui_impl_opengl3.h>
|
|
|
|
|
2024-08-10 19:12:21 -04:00
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "Scene.h"
|
|
|
|
|
2024-08-11 14:52:38 -04:00
|
|
|
void Scene::DrawGUI(GLFWwindow* window) {
|
2024-08-11 21:20:17 -04:00
|
|
|
// Begin ImGui frame
|
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
ImGui_ImplGlfw_NewFrame();
|
|
|
|
|
|
|
|
// Enable docking
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
|
|
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
|
|
|
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode;
|
|
|
|
|
|
|
|
// Add menu bar
|
|
|
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
|
|
|
|
|
|
|
// Style windows
|
|
|
|
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
|
|
|
ImGui::SetNextWindowPos(viewport->WorkPos);
|
|
|
|
ImGui::SetNextWindowSize(viewport->WorkSize);
|
|
|
|
ImGui::SetNextWindowViewport(viewport->ID);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
|
|
|
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
|
|
|
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
|
|
|
window_flags |= ImGuiWindowFlags_NoBackground;
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
|
|
|
ImGui::Begin("TerraVisor", nullptr, window_flags);
|
|
|
|
ImGui::PopStyleVar(3);
|
|
|
|
|
|
|
|
// Submit the DockSpace
|
|
|
|
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
|
|
|
{
|
|
|
|
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
|
|
|
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::BeginMenuBar())
|
|
|
|
{
|
|
|
|
if (ImGui::BeginMenu("Options"))
|
|
|
|
{
|
|
|
|
ImGui::Text("Nothing Here Yet, Check Back Later!");
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
//Draw Gui
|
|
|
|
ImGui::Begin("Terrain Controls");
|
|
|
|
if (ImGui::Button("Quit"))
|
|
|
|
{
|
|
|
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
ImGui::Render();
|
|
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
2024-08-10 19:12:21 -04:00
|
|
|
}
|
|
|
|
|
2024-08-11 14:52:38 -04:00
|
|
|
void Scene::Display(GLFWwindow* window) {
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
2024-08-11 21:20:17 -04:00
|
|
|
|
|
|
|
Scene::DrawGUI(window);
|
|
|
|
|
2024-08-11 14:52:38 -04:00
|
|
|
glfwSwapBuffers(window);
|
2024-08-10 19:12:21 -04:00
|
|
|
}
|
|
|
|
|
2024-08-11 14:52:38 -04:00
|
|
|
void Scene::Idle() {
|
2024-08-10 19:12:21 -04:00
|
|
|
}
|
|
|
|
|
2024-08-11 14:52:38 -04:00
|
|
|
void Scene::Init() {
|
|
|
|
glewInit();
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glEnable(GL_CULL_FACE);
|
2024-08-10 19:12:21 -04:00
|
|
|
}
|