Commit 22b96576 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

unix: fix gui main function

parent 0ae07d60
......@@ -2,12 +2,13 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "imgui.h"
#include "application.hpp"
#include "imnodes.hpp"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "gui.hpp"
#include "imnodes.hpp"
#include <cstdio>
#include <cstring>
......@@ -36,7 +37,7 @@
// legacy_stdio_definitions.lib, which we do using this pragma. Your own
// project should not be affected, as you are likely to link with a newer
// binary of GLFW that is adequate for your version of Visual Studio.
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && \
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && \
!defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
#pragma comment(lib, "legacy_stdio_definitions")
#endif
......@@ -79,8 +80,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
#endif
// Create window with graphics context
GLFWwindow* window = glfwCreateWindow(
1280, 720, "irritator", NULL, NULL);
GLFWwindow* window = glfwCreateWindow(1280, 720, "irritator", NULL, NULL);
if (window == NULL)
return 1;
glfwMakeContextCurrent(window);
......@@ -94,9 +94,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
bool err = gladLoadGL() == 0;
#else
bool err =
false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader
// is likely to requires some form of initialization.
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader
// is likely to requires some form of initialization.
#endif
if (err) {
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
......@@ -120,7 +119,18 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
imnodes::CreateContext();
irt::application_initialize();
irt::application app;
if (!app.init()) {
imnodes::DestroyContext();
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
}
// Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can
......@@ -147,8 +157,8 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
// io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f,
// NULL, io.Fonts->GetGlyphRangesJapanese()); IM_ASSERT(font != NULL);
//bool show_demo_window = true;
//bool show_another_window = false;
// bool show_demo_window = true;
// bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
// Main loop
......@@ -169,7 +179,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
if (!irt::application_show())
if (!app.show())
glfwSetWindowShouldClose(window, GLFW_TRUE);
// Rendering
......@@ -189,7 +199,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
// Cleanup
irt::application_shutdown();
app.shutdown();
imnodes::DestroyContext();
ImGui_ImplOpenGL3_Shutdown();
......@@ -201,4 +211,3 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment