From cf38b449c5c66cfda0252fe1cf74fa996ac4fa77 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 28 Dec 2018 00:53:05 +0100 Subject: [PATCH] imgui changes --- external/imgui/CMakeLists.txt | 5 +++ rwgame/RWImGui.cpp | 79 +---------------------------------- 2 files changed, 6 insertions(+), 78 deletions(-) diff --git a/external/imgui/CMakeLists.txt b/external/imgui/CMakeLists.txt index 700dc127..1befa8fd 100644 --- a/external/imgui/CMakeLists.txt +++ b/external/imgui/CMakeLists.txt @@ -21,6 +21,11 @@ target_compile_definitions(imgui IMGUI_USER_CONFIG="${CMAKE_CURRENT_SOURCE_DIR}/rw_imconfig.h" ) +target_link_libraries(imgui + PUBLIC + openrw::checks +) + add_library(imgui::core ALIAS imgui) openrw_target_apply_options( diff --git a/rwgame/RWImGui.cpp b/rwgame/RWImGui.cpp index a9ac63d0..d3affa05 100644 --- a/rwgame/RWImGui.cpp +++ b/rwgame/RWImGui.cpp @@ -56,8 +56,7 @@ void RWImGui::tick() { ImGui::SetCurrentContext(_context); auto& io = ImGui::GetIO(); - SDL_Window *window; - std::tie(window, std::ignore) = _game.getWindow().getSDLContext(); + auto [window, sdl_glcontext] = _game.getWindow().getSDLContext(); ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(window); @@ -79,82 +78,6 @@ void RWImGui::tick() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); } -static ImGuiIO *g_io; - -static SDL_Window *g_sdl_window; -static SDL_GLContext g_sdl_gl_context; - - -void imgui_init(SDL_Window *sdl_window, SDL_GLContext sdl_gl_context) { - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - g_io = &ImGui::GetIO(); - - g_sdl_window = sdl_window; - g_sdl_gl_context = sdl_gl_context; - - ImGui_ImplSDL2_InitForOpenGL(sdl_window, sdl_gl_context); - ImGui_ImplOpenGL3_Init("#version 150"); - -// ImGui::StyleColorsDark(); -// ImGui::StyleColorsClassic(); - ImGui::StyleColorsLight(); - - - // Build atlas - unsigned char* tex_pixels = NULL; - int tex_w, tex_h; - g_io->Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h); -} - -void imgui_process_event(SDL_Event *event, bool *mouse, bool *keyboard) { - ImGui_ImplSDL2_ProcessEvent(event); - *mouse = g_io->WantCaptureMouse; - *keyboard = g_io->WantCaptureKeyboard; -} - -static bool show_demo_window = true; - -void imgui_tick() { - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(g_sdl_window); - ImGui::NewFrame(); - -// g_io->DisplaySize = ImVec2(1920, 1080); -// g_io->DeltaTime = 1.0f / 60.0f; - - static float f = 0.0f; - - ImGui::Begin("Hello, world!"); - ImGui::Text("Hello, world!"); - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", static_cast(1000.0f / g_io->Framerate), static_cast(g_io->Framerate)); - ImGui::End(); - - if (show_demo_window) { - ImGui::ShowDemoWindow(&show_demo_window); - } - -// ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - ImGui::Render(); -// SDL_GL_MakeCurrent(g_sdl_window, g_sdl_gl_context); -// glViewport(0, 0, static_cast(g_io->DisplaySize.x), static_cast(g_io->DisplaySize.y)); -// glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); -// glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); -// SDL_GL_SwapWindow(g_sdl_window); -} - -void imgui_destroy() { - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - g_io = nullptr; - g_sdl_gl_context = nullptr; - g_sdl_window = nullptr; -} - #else RWImGui::RWImGui(RWGame &game)