use atexit
This commit is contained in:
parent
fb2bafb215
commit
26af4416c2
23
main.cpp
23
main.cpp
|
@ -1,3 +1,5 @@
|
|||
#include <cstdlib>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <imgui.h>
|
||||
|
@ -8,23 +10,33 @@ int main(int, char**)
|
|||
{
|
||||
if (!glfwInit())
|
||||
return 1;
|
||||
std::atexit(glfwTerminate);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
GLFWwindow* window = glfwCreateWindow(1900, 720, "microsa", nullptr, nullptr);
|
||||
static GLFWwindow* window = glfwCreateWindow(1900, 720, "microsa", nullptr, nullptr);
|
||||
if (window == nullptr) {
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
static auto DestroyWindow = []() {
|
||||
glfwDestroyWindow(window);
|
||||
};
|
||||
std::atexit(DestroyWindow);
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
static auto ImGuiDestroyContext = []() {
|
||||
ImGui::DestroyContext();
|
||||
};
|
||||
std::atexit(ImGuiDestroyContext);
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
std::atexit(ImGui_ImplGlfw_Shutdown);
|
||||
ImGui_ImplOpenGL3_Init("#version 130");
|
||||
std::atexit(ImGui_ImplOpenGL3_Shutdown);
|
||||
|
||||
int waterfall_width = 1600;
|
||||
int waterfall_height = 700;
|
||||
|
@ -86,12 +98,5 @@ int main(int, char**)
|
|||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue