From 4b3dc4d91b12de71d95c039015791ceb9e77c4cf Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Wed, 17 Jun 2020 19:56:06 +0200 Subject: [PATCH] Setting a simple ugly class --- MainWindow.cpp | 260 ++++++++++++++++++++++++++++++++++++++++++++++++ MainWindow.h | 39 ++++++++ Makefile | 2 +- imgui.ini | 8 +- main.cpp | 265 +------------------------------------------------ 5 files changed, 308 insertions(+), 266 deletions(-) create mode 100644 MainWindow.cpp create mode 100644 MainWindow.h diff --git a/MainWindow.cpp b/MainWindow.cpp new file mode 100644 index 0000000..927f84b --- /dev/null +++ b/MainWindow.cpp @@ -0,0 +1,260 @@ +#include "MainWindow.h" + +std::shared_ptr<MainWindow> MainWindow::self = nullptr; +Uint32 MainWindow::wakeup_on_mpv_render_update = 0; +Uint32 MainWindow::wakeup_on_mpv_events = 0; + + int __one[] = {1}; + mpv_opengl_init_params mpv_gl_init_params = { + .get_proc_address = [] (void *, const char *name) -> void * { return SDL_GL_GetProcAddress(name); }, + }; + + mpv_render_param params[] = { + {MPV_RENDER_PARAM_API_TYPE, (void *) MPV_RENDER_API_TYPE_OPENGL}, + {MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &mpv_gl_init_params}, + {MPV_RENDER_PARAM_ADVANCED_CONTROL, &__one}, /* Async commands only */ + {(mpv_render_param_type)0} + }; + + +MainWindow::MainWindow(void) : + show_demo_window(true), show_another_window(false), clear_color(0.45f, 0.55f, 0.60f, 1.00f), + mpv_gl(nullptr), mpv(mpv_create()) +{ + if (!mpv) + throw 1; /* TODO */ + + /* Do prior mpv init (idle flag) */ + if (mpv_initialize(mpv) < 0) + throw 1; + + mpv_request_log_messages(mpv, "debug"); + SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "no"); // Jesus Christ SDL, you suck! + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) + { + printf("Error: %s\n", SDL_GetError()); + throw 1; + } + + // GL 3.0 + GLSL 130 + const char* glsl_version = "#version 130"; + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + + // Create window with graphics context + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); + window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); + gl_context = SDL_GL_CreateContext(window); + SDL_GL_MakeCurrent(window, gl_context); + SDL_GL_SetSwapInterval(1); // Enable vsync + + // Initialize OpenGL loader + if (gl3wInit()) + { + fprintf(stderr, "Failed to initialize OpenGL loader!\n"); + throw 1; + } + + if (mpv_render_context_create(&mpv_gl, mpv, params) < 0) /* Resolv already created context */ + throw 1; + + wakeup_on_mpv_render_update = SDL_RegisterEvents(1); + wakeup_on_mpv_events = SDL_RegisterEvents(1); + if (wakeup_on_mpv_render_update == (Uint32)-1 || wakeup_on_mpv_events == (Uint32)-1) + throw 1; + + // When normal mpv events are available. + mpv_set_wakeup_callback(mpv, [](void *) -> void {SDL_Event event = {.type = wakeup_on_mpv_events}; SDL_PushEvent(&event);}, NULL); + // When there is a need to call mpv_render_context_update(), which can request a new frame to be rendered. + mpv_render_context_set_update_callback(mpv_gl, [](void *) -> void { SDL_Event event = {.type = wakeup_on_mpv_render_update}; SDL_PushEvent(&event); }, NULL); + + // Play this file. + const char *cmd[] = {"loadfile", "/home/kubat/aeiie/karaoke/flipflappers/is8.mp4", NULL}; + mpv_command_async(mpv, 0, cmd); + + // Setup Dear ImGui context + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + io = &ImGui::GetIO(); + io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; + io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; + io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; + ImGui::StyleColorsDark(); + ImGui_ImplSDL2_InitForOpenGL(window, gl_context); + ImGui_ImplOpenGL3_Init(glsl_version); + + // Out windows look the same as the in primary window + style = &ImGui::GetStyle(); + style->WindowRounding = 0.0f; + style->Colors[ImGuiCol_WindowBg].w = 1.0f; + + assert(io->Fonts->AddFontDefault()); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); +} + +void +MainWindow::Init(void) +{ + if (self) + return; + self = std::shared_ptr<MainWindow>(new MainWindow()); +} + +void +MainWindow::DeInit(void) +{ + mpv_render_context_free(mpv_gl); + mpv_detach_destroy(mpv); + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplSDL2_Shutdown(); + ImGui::DestroyContext(); + SDL_GL_DeleteContext(gl_context); + SDL_DestroyWindow(window); + SDL_Quit(); + exit(0); +} + +void +MainWindow::Main(void) +{ + bool done = false; + while (!done) + { + // Poll and handle events (inputs, window resize, etc.) + // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. + // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. + // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. + // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. + SDL_Event event; + while (SDL_PollEvent(&event)) + { + ImGui_ImplSDL2_ProcessEvent(&event); + if (event.type == SDL_QUIT) + done = true; + if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) + done = true; + if (event.type == SDL_KEYDOWN) + { + if (event.key.keysym.sym == SDLK_SPACE) + { + const char *cmd_pause[] = {"cycle", "pause", NULL}; + mpv_command_async(mpv, 0, cmd_pause); + } + if (event.key.keysym.sym == SDLK_s) + { + // Also requires MPV_RENDER_PARAM_ADVANCED_CONTROL if you want + // screenshots to be rendered on GPU (like --vo=gpu would do). + const char *cmd_scr[] = {"screenshot-to-file", + "screenshot.png", + "window", + NULL}; + printf("attempting to save screenshot to %s\n", cmd_scr[1]); + mpv_command_async(mpv, 0, cmd_scr); + } + } + if (event.type == wakeup_on_mpv_render_update) + { + // Need to be called to update + mpv_render_context_update(mpv_gl); + } + // Happens when at least 1 new event is in the mpv event queue. + if (event.type == wakeup_on_mpv_events) + { + // Handle all remaining mpv events. + int count = 10; + while (count) { + mpv_event *mp_event = (mpv_event*) mpv_wait_event(mpv, 0); + if (mp_event->event_id == MPV_EVENT_NONE) + break; + if (mp_event->event_id == MPV_EVENT_LOG_MESSAGE) { + mpv_event_log_message *msg = (mpv_event_log_message *) mp_event->data; + if (strstr(msg->text, "DR image")) + printf("log: %s", msg->text); + continue; + } + count --; + printf("event: %s\n", mpv_event_name(mp_event->event_id)); + } + } + } + + // Start the Dear ImGui frame + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(window); + ImGui::NewFrame(); + + // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). + if (show_demo_window) + ImGui::ShowDemoWindow(&show_demo_window); + + // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. + { + static float f = 0.0f; + static int counter = 0; + + ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. + + ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) + ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state + ImGui::Checkbox("Another Window", &show_another_window); + + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f + ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color + + if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) + counter++; + ImGui::SameLine(); + ImGui::Text("counter = %d", counter); + + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); + ImGui::End(); + } + + // 3. Show another simple window. + if (show_another_window) + { + ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) + ImGui::Text("Hello from another window!"); + if (ImGui::Button("Close Me")) + show_another_window = false; + ImGui::End(); + } + + // Rendering + ImGui::Render(); + + /* Always redraw */ + int w, h; + int __one__one = 1; + SDL_GetWindowSize(window, &w, &h); + mpv_opengl_fbo fbo = { + .fbo = 0, + .w = w, + .h = h, + }; + mpv_render_param params[] = { + {MPV_RENDER_PARAM_OPENGL_FBO, &fbo}, + {MPV_RENDER_PARAM_FLIP_Y, &__one__one}, + {(mpv_render_param_type)0} + }; + // mpv_render_context_render(mpv_gl, params); + + SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); + SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext(); + ImGui::UpdatePlatformWindows(); + ImGui::RenderPlatformWindowsDefault(); + SDL_GL_MakeCurrent(backup_current_window, backup_current_context); + mpv_render_context_render(mpv_gl, params); + + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + SDL_GL_SwapWindow(window); + } + + DeInit(); +} diff --git a/MainWindow.h b/MainWindow.h new file mode 100644 index 0000000..0a85899 --- /dev/null +++ b/MainWindow.h @@ -0,0 +1,39 @@ +#pragma once + +#include "imgui.h" +#include "imgui_impl_sdl.h" +#include "imgui_impl_opengl3.h" +#include <memory> +#include <SDL.h> +#include <mpv/client.h> +#include <mpv/render_gl.h> +#include <GL/gl3w.h> + +class MainWindow +{ +private: + bool show_demo_window; + bool show_another_window; + ImVec4 clear_color; + mpv_render_context *mpv_gl; + mpv_handle *mpv; + + SDL_WindowFlags window_flags; + SDL_Window* window; + SDL_GLContext gl_context; + ImGuiIO *io; + ImGuiStyle *style; + + static Uint32 wakeup_on_mpv_render_update, wakeup_on_mpv_events; /* Need to be static */ + static std::shared_ptr<MainWindow> self; + + MainWindow(void); + void DeInit(void); + +public: + void Main(void); + + static void Init(void); + + static inline std::shared_ptr<MainWindow>& GetInstance(void) { return self; } +}; diff --git a/Makefile b/Makefile index 59ad856..e7609e6 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ CXX = clang++ EXE = example_sdl_opengl3 -SOURCES = main.cpp +SOURCES = main.cpp MainWindow.cpp SOURCES += imgui_impl_sdl.cpp imgui_impl_opengl3.cpp SOURCES += imgui.cpp imgui_demo.cpp imgui_draw.cpp imgui_widgets.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) diff --git a/imgui.ini b/imgui.ini index e0339bb..e8c0f80 100644 --- a/imgui.ini +++ b/imgui.ini @@ -4,13 +4,13 @@ Size=400,400 Collapsed=0 [Window][Hello, world!] -Pos=166,90 -Size=660,407 +Pos=225,155 +Size=642,389 Collapsed=0 [Window][Dear ImGui Demo] -Pos=997,69 -Size=750,497 +Pos=1019,130 +Size=744,491 Collapsed=0 [Window][Another Window] diff --git a/main.cpp b/main.cpp index 0e34694..594616b 100644 --- a/main.cpp +++ b/main.cpp @@ -1,264 +1,7 @@ -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_opengl3.h" -#include <stdio.h> -#include <SDL.h> -#include <mpv/client.h> -#include <mpv/render_gl.h> -#include <GL/gl3w.h> +#include "MainWindow.h" -// Main code -int main(int argc, char **argv) +int main(void) { - // MPV init before SDL init - // If I remenber, we need to set an idle thing for mpv, so that it won't close even after the end of the video (which is facheux) - if (argc != 2) - return 1; - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - static Uint32 wakeup_on_mpv_render_update, wakeup_on_mpv_events; /* Need to be static */ - mpv_render_context *mpv_gl; - mpv_handle *mpv = mpv_create(); - if (!mpv) - return 1; - - // Some minor options can only be set before mpv_initialize(). (XXX: The idle flag) - if (mpv_initialize(mpv) < 0) - return 1; - - mpv_request_log_messages(mpv, "debug"); - SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "no"); // Jesus Christ SDL, you suck! - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // GL 3.0 + GLSL 130 - const char* glsl_version = "#version 130"; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); - - // Create window with graphics context - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - SDL_GLContext gl_context = SDL_GL_CreateContext(window); - SDL_GL_MakeCurrent(window, gl_context); - SDL_GL_SetSwapInterval(1); // Enable vsync - - // Initialize OpenGL loader - if (gl3wInit()) - { - fprintf(stderr, "Failed to initialize OpenGL loader!\n"); - return 1; - } - - int __one[] = {1}; - mpv_opengl_init_params mpv_gl_init_params = { - .get_proc_address = [] (void *, const char *name) -> void * { return SDL_GL_GetProcAddress(name); }, - }; - - mpv_render_param params[] = { - {MPV_RENDER_PARAM_API_TYPE, (void *) MPV_RENDER_API_TYPE_OPENGL}, - {MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &mpv_gl_init_params}, - {MPV_RENDER_PARAM_ADVANCED_CONTROL, &__one}, /* Async commands only */ - {(mpv_render_param_type)0} - }; - - if (mpv_render_context_create(&mpv_gl, mpv, params) < 0) /* Resolv already created context */ - return 1; - - wakeup_on_mpv_render_update = SDL_RegisterEvents(1); - wakeup_on_mpv_events = SDL_RegisterEvents(1); - if (wakeup_on_mpv_render_update == (Uint32)-1 || wakeup_on_mpv_events == (Uint32)-1) - return 1; - - // When normal mpv events are available. - mpv_set_wakeup_callback(mpv, [](void *) -> void {SDL_Event event = {.type = wakeup_on_mpv_events}; SDL_PushEvent(&event);}, NULL); - // When there is a need to call mpv_render_context_update(), which can request a new frame to be rendered. - mpv_render_context_set_update_callback(mpv_gl, [](void *) -> void { SDL_Event event = {.type = wakeup_on_mpv_render_update}; SDL_PushEvent(&event); }, NULL); - - // Play this file. - const char *cmd[] = {"loadfile", argv[1], NULL}; - mpv_command_async(mpv, 0, cmd); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; - io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; - ImGui::StyleColorsDark(); - ImGui_ImplSDL2_InitForOpenGL(window, gl_context); - ImGui_ImplOpenGL3_Init(glsl_version); - - // Out windows look the same as the in primary window - ImGuiStyle& style = ImGui::GetStyle(); - if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) - { - style.WindowRounding = 0.0f; - style.Colors[ImGuiCol_WindowBg].w = 1.0f; - } - - assert(io.Fonts->AddFontDefault()); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym == SDLK_SPACE) - { - const char *cmd_pause[] = {"cycle", "pause", NULL}; - mpv_command_async(mpv, 0, cmd_pause); - } - if (event.key.keysym.sym == SDLK_s) - { - // Also requires MPV_RENDER_PARAM_ADVANCED_CONTROL if you want - // screenshots to be rendered on GPU (like --vo=gpu would do). - const char *cmd_scr[] = {"screenshot-to-file", - "screenshot.png", - "window", - NULL}; - printf("attempting to save screenshot to %s\n", cmd_scr[1]); - mpv_command_async(mpv, 0, cmd_scr); - } - } - if (event.type == wakeup_on_mpv_render_update) - { - // Need to be called to update - mpv_render_context_update(mpv_gl); - } - // Happens when at least 1 new event is in the mpv event queue. - if (event.type == wakeup_on_mpv_events) - { - // Handle all remaining mpv events. - int count = 10; - while (count) { - mpv_event *mp_event = (mpv_event*) mpv_wait_event(mpv, 0); - if (mp_event->event_id == MPV_EVENT_NONE) - break; - if (mp_event->event_id == MPV_EVENT_LOG_MESSAGE) { - mpv_event_log_message *msg = (mpv_event_log_message *) mp_event->data; - if (strstr(msg->text, "DR image")) - printf("log: %s", msg->text); - continue; - } - count --; - printf("event: %s\n", mpv_event_name(mp_event->event_id)); - } - } - } - - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(window); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - - /* Always redraw */ - int w, h; - int __one__one = 1; - SDL_GetWindowSize(window, &w, &h); - mpv_opengl_fbo fbo = { - .fbo = 0, - .w = w, - .h = h, - }; - mpv_render_param params[] = { - {MPV_RENDER_PARAM_OPENGL_FBO, &fbo}, - {MPV_RENDER_PARAM_FLIP_Y, &__one__one}, - {(mpv_render_param_type)0} - }; - // mpv_render_context_render(mpv_gl, params); - - if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) - { - SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); - SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); - SDL_GL_MakeCurrent(backup_current_window, backup_current_context); - } - mpv_render_context_render(mpv_gl, params); - - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - - SDL_GL_SwapWindow(window); - } - - /* CLEAN */ - mpv_render_context_free(mpv_gl); - mpv_detach_destroy(mpv); - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - SDL_GL_DeleteContext(gl_context); - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; + MainWindow::Init(); + MainWindow::GetInstance()->Main(); } -- GitLab