Extract sidebar, lifecycle shell, and canvas unmerged draw
This commit is contained in:
62
src/main.cpp
62
src/main.cpp
@@ -11,6 +11,7 @@
|
||||
#include "legacy_preference_storage.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
#include "platform_windows/windows_platform_services.h"
|
||||
#include "platform_windows/windows_lifecycle_shell.h"
|
||||
#include "platform_windows/windows_splash.h"
|
||||
#include "platform_windows/windows_stylus_input.h"
|
||||
#include "platform_windows/windows_vr_shell.h"
|
||||
@@ -30,10 +31,6 @@
|
||||
#include <iomanip>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <atomic>
|
||||
|
||||
#define WM_USER_CLOSE (WM_USER + 1)
|
||||
#define WM_USER_WAKEUP (WM_USER + 2)
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
|
||||
namespace pp::platform::windows {
|
||||
@@ -127,13 +124,10 @@ void pp_windows_enqueue_main_task(std::packaged_task<void()> task)
|
||||
enqueue_main_task_bridge(std::move(task));
|
||||
}
|
||||
|
||||
std::atomic<int> running{-1};
|
||||
|
||||
void destroy_window()
|
||||
{
|
||||
auto& state = retained_state();
|
||||
enqueue_main_task([hWnd = state.hWnd] {
|
||||
PostMessage(hWnd, WM_USER_CLOSE, 0, 0);
|
||||
enqueue_main_task([hWnd = retained_state().hWnd] {
|
||||
pp::platform::windows::request_window_close(hWnd);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -159,25 +153,15 @@ void async_unlock()
|
||||
|
||||
void win32_update_stylus(float dt)
|
||||
{
|
||||
pp::platform::windows::update_stylus_state(dt);
|
||||
pp::platform::windows::update_stylus_frame(dt);
|
||||
}
|
||||
|
||||
void win32_update_fps(int frames)
|
||||
{
|
||||
static wchar_t title_fps[512];
|
||||
auto& state = retained_state();
|
||||
const int vr_fps = pp::platform::windows::current_vr_fps(state.vr);
|
||||
if (App::I->vr_active)
|
||||
swprintf_s(title_fps, L"%s - %d fps - %d vr fps", state.window_title, frames, vr_fps);
|
||||
else
|
||||
swprintf_s(title_fps, L"%s - %d fps", state.window_title, frames);
|
||||
|
||||
{
|
||||
enqueue_main_task([hWnd = state.hWnd] {
|
||||
SetWindowText(hWnd, title_fps);
|
||||
});
|
||||
}
|
||||
PostMessage(state.hWnd, WM_USER_WAKEUP, 0, 0);
|
||||
enqueue_main_task([hWnd = state.hWnd, window_title = state.window_title, &vr = state.vr, frames] {
|
||||
pp::platform::windows::update_window_fps(hWnd, window_title, vr, frames);
|
||||
});
|
||||
}
|
||||
|
||||
int read_WMI_info()
|
||||
@@ -455,25 +439,17 @@ void init_vk_map()
|
||||
bool win32_vr_start()
|
||||
{
|
||||
auto& state = retained_state();
|
||||
return pp::platform::windows::start_vr_shell(state.vr, state.sandboxed, running);
|
||||
return pp::platform::windows::start_window_vr(state.vr, state.sandboxed);
|
||||
}
|
||||
|
||||
void win32_vr_stop()
|
||||
{
|
||||
auto& state = retained_state();
|
||||
pp::platform::windows::stop_vr_shell(state.vr);
|
||||
pp::platform::windows::stop_window_vr(retained_state().vr);
|
||||
}
|
||||
|
||||
void win32_save_window_state()
|
||||
{
|
||||
auto& state = retained_state();
|
||||
WINDOWPLACEMENT p;
|
||||
GetWindowPlacement(state.hWnd, &p);
|
||||
pp::panopainter::set_legacy_window_preferences(p.showCmd, {
|
||||
p.rcNormalPosition.left,
|
||||
p.rcNormalPosition.top,
|
||||
p.rcNormalPosition.right,
|
||||
p.rcNormalPosition.bottom });
|
||||
pp::platform::windows::save_window_preferences(retained_state().hWnd);
|
||||
}
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@@ -678,7 +654,7 @@ int main(int argc, char** argv)
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
|
||||
running.store(1, std::memory_order_relaxed);
|
||||
pp::platform::windows::mark_lifecycle_running();
|
||||
App::I->runtime().render_thread_start(*App::I);
|
||||
App::I->runtime().ui_thread_start(*App::I);
|
||||
|
||||
@@ -724,14 +700,14 @@ int main(int argc, char** argv)
|
||||
|
||||
MSG msg;
|
||||
LOG("start main loop");
|
||||
while (running.load(std::memory_order_relaxed) == 1)
|
||||
while (pp::platform::windows::lifecycle_is_running())
|
||||
{
|
||||
// If there any message in the queue process it
|
||||
auto present = App::I->animate || App::I->redraw ?
|
||||
PeekMessage(&msg, 0, 0, 0, PM_REMOVE) : GetMessage(&msg, 0, 0, 0);
|
||||
|
||||
if (msg.message == WM_QUIT)
|
||||
running.store(0, std::memory_order_relaxed);
|
||||
pp::platform::windows::mark_lifecycle_stopped();
|
||||
|
||||
if (present)
|
||||
{
|
||||
@@ -762,14 +738,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_USER_CLOSE:
|
||||
running.store(0, std::memory_order_relaxed);
|
||||
pp::platform::windows::request_stop_and_join_vr_thread(state.vr);
|
||||
App::I->runtime().ui_thread_stop();
|
||||
App::I->runtime().render_thread_stop();
|
||||
App::I->terminate();
|
||||
delete App::I;
|
||||
PostQuitMessage(0);
|
||||
case pp::platform::windows::kUserCloseMessage:
|
||||
pp::platform::windows::handle_window_close_message(state.vr);
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
App::I->redraw = true;
|
||||
@@ -792,7 +762,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
{
|
||||
auto w = (float)LOWORD(lp);
|
||||
auto h = (float)HIWORD(lp);
|
||||
if (h != 0 && running.load(std::memory_order_relaxed) == 1)
|
||||
if (h != 0 && pp::platform::windows::lifecycle_is_running())
|
||||
{
|
||||
App::I->ui_task_async([=]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user