From f5d885a3f4ab1f9e8eabe0b54762944a36206e3b Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 10 Jul 2019 23:02:43 +0200 Subject: [PATCH] cleanup code --- src/main.cpp | 121 ++------------------------------------------------- 1 file changed, 4 insertions(+), 117 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7070a0e..a404796 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -715,7 +715,7 @@ LRESULT CALLBACK splash_proc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lPara return TRUE; } - case WM_USER + 1: + case WM_USER_CLOSE: PostQuitMessage(0); return TRUE; } @@ -980,9 +980,6 @@ int main(int argc, char** argv) glad_set_post_callback(_post_call_callback); #endif - LOG("init app"); - // App::I.init(); - if (!sandboxed) { LOG("init WinTab"); @@ -997,6 +994,8 @@ int main(int argc, char** argv) SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON1))); + App::I.ui_sync(); + { WINDOWPLACEMENT wp; GetWindowPlacement(hWnd, &wp); @@ -1007,115 +1006,6 @@ int main(int argc, char** argv) //App::I.height = clientRect.bottom - clientRect.top; } - /* - ui_renderer = std::thread([&] { - BT_SetTerminate(); - LOG("start render thread"); - const float target_fps = 10; - const float target_tick_rate = 10; - unsigned long t0 = GetTickCount64(); - unsigned long t1; - int frames = 0; - float one_sec = 0; - float render_timer = 0; - float frame_timer = 0; - while(running == 1) - { - t1 = GetTickCount64(); - float dt = (float)(t1 - t0) / 1000.0f; - one_sec += dt; - render_timer += dt; - frame_timer += dt; - timer_stylus += dt; - timer_ink_touch += dt; - timer_ink_pen += dt; - - if (one_sec > 1.f) - { - static wchar_t title_fps[512]; - if (App::I.vr_active) - swprintf_s(title_fps, L"%s - %d fps - %d vr fps", window_title, frames, vr_frames); - else - swprintf_s(title_fps, L"%s - %d fps", window_title, frames); - - std::lock_guard lock(main_task_mutex); - main_tasklist.emplace_back([=] { - SetWindowText(hWnd, title_fps); - }); - - one_sec = 0; - frames = 0; - } - - { - std::deque> working_list; - { - std::lock_guard lock(task_mutex); - working_list = std::move(tasklist); - } - - if (!working_list.empty()) - { - while (!working_list.empty()) - { - working_list.front()(); - working_list.pop_front(); - } - //LOG("clear"); - //WacomTablet::I.m_stylus = false; - //WacomTablet::I.m_eraser = false; - } - } - - App::I.tick(dt); - - std::unique_lock lock(ui_render_mutex); - if (render_timer > 1.0f / target_fps) - { - App::I.redraw = true; - render_timer = 0; - } - if (timer_stylus > 0.1 && (WacomTablet::I.m_stylus || WacomTablet::I.m_eraser)) - { - WacomTablet::I.m_stylus = false; - WacomTablet::I.m_eraser = false; - App::I.redraw = true; - } - if (timer_ink_pen > 0.1 && WacomTablet::I.m_ink_pen) - { - WacomTablet::I.m_ink_pen = false; - App::I.redraw = true; - } - if (timer_ink_touch > 0.1 && WacomTablet::I.m_ink_touch) - { - WacomTablet::I.m_ink_touch = false; - App::I.redraw = true; - } - - if (App::I.redraw) - { - App::I.update(frame_timer); - App::I.render_task([frame_timer] - { - glBindFramebuffer(GL_FRAMEBUFFER, 0); - App::I.clear(); - App::I.draw(frame_timer); - SwapBuffers(hDC); - }); - frame_timer = 0; - frames++; - } - - const int framerate = (1.f / target_tick_rate) * 1000; - const int diff = framerate - (t1 - t0); - //render_cv.wait_for(lock, std::chrono::milliseconds(diff)); - //std::this_thread::sleep_for(std::chrono::milliseconds(30)); - t0 = t1; - } - }); - */ - SetTimer(hWnd, 1, 500, NULL); - if (start_in_vr) App::I.vr_start(); @@ -1123,7 +1013,7 @@ int main(int argc, char** argv) SetForegroundWindow(hWnd); //ShowWindow(hWnd, show_cmd); - SendMessage(splash_dialog, WM_USER + 1, 0, 0); + SendMessage(splash_dialog, WM_USER_CLOSE, 0, 0); if (dialog_thread.joinable()) dialog_thread.join(); @@ -1161,9 +1051,6 @@ int main(int argc, char** argv) } } } - -// if (!tasklist.empty()) -// ui_render_cv.notify_all(); } // Clean up WacomTablet::I.terminate();