Extract brush panel UI, app startup shell, and Win32 runtime shell
This commit is contained in:
143
src/app.cpp
143
src/app.cpp
@@ -18,12 +18,8 @@
|
||||
#include "legacy_app_startup_services.h"
|
||||
#include "legacy_document_open_services.h"
|
||||
#include "legacy_document_session_services.h"
|
||||
#include "legacy_gl_runtime_dispatch.h"
|
||||
#include "legacy_preference_storage.h"
|
||||
#include "legacy_recording_services.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Foundation/Foundation.h>
|
||||
@@ -32,36 +28,9 @@
|
||||
|
||||
App* App::I = nullptr; // singleton
|
||||
|
||||
[[nodiscard]] GLenum linear_texture_filter() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::linear_texture_filter());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum nearest_texture_filter() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::nearest_texture_filter());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum repeat_texture_wrap() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::repeat_texture_wrap());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum framebuffer_target() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::framebuffer_target());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLuint default_framebuffer_id() noexcept
|
||||
{
|
||||
return static_cast<GLuint>(pp::renderer::gl::default_framebuffer_id());
|
||||
}
|
||||
|
||||
void App::create()
|
||||
{
|
||||
const auto initial_surface = pp::app::plan_app_initial_surface();
|
||||
width = initial_surface.width;
|
||||
height = initial_surface.height;
|
||||
pp::panopainter::execute_legacy_app_create(*this);
|
||||
}
|
||||
|
||||
void App::open_document(std::string path)
|
||||
@@ -107,39 +76,12 @@ void App::clear()
|
||||
|
||||
void App::initAssets()
|
||||
{
|
||||
LOG("initializing assets");
|
||||
FontManager::init();
|
||||
|
||||
LOG("initializing assets create sampler");
|
||||
sampler.create(nearest_texture_filter());
|
||||
sampler_stencil.create(linear_texture_filter(), repeat_texture_wrap());
|
||||
sampler_linear.create(linear_texture_filter());
|
||||
m_face_plane.create<1>(2, 2);
|
||||
sphere.create<8, 8>(1);
|
||||
LOG("initializing assets load uvs texture");
|
||||
LOG("initializing assets completed");
|
||||
pp::panopainter::execute_legacy_app_init_assets(*this);
|
||||
}
|
||||
|
||||
void App::initLog()
|
||||
{
|
||||
const auto paths = prepare_storage_paths();
|
||||
if (!paths.data_path.empty())
|
||||
data_path = paths.data_path;
|
||||
if (!paths.recording_path.empty())
|
||||
rec_path = paths.recording_path;
|
||||
if (!paths.temporary_path.empty())
|
||||
tmp_path = paths.temporary_path;
|
||||
|
||||
// TODO: save this path somewhere in the settings, don't overwrite every start
|
||||
work_path = paths.work_path.empty() ? data_path : paths.work_path;
|
||||
|
||||
//LogRemote::I.start();
|
||||
LogRemote::I.file_init();
|
||||
LOG("%s", g_version);
|
||||
|
||||
LOG("load preferences");
|
||||
if (!pp::panopainter::load_legacy_preferences())
|
||||
LOG("load preferences failed");
|
||||
pp::panopainter::execute_legacy_app_init_log(*this);
|
||||
}
|
||||
|
||||
namespace pp::panopainter
|
||||
@@ -183,84 +125,7 @@ bool App::check_license()
|
||||
|
||||
void App::init()
|
||||
{
|
||||
LOG("Screen Resolution: %dx%d", (int)width, (int)height);
|
||||
|
||||
render_task([]
|
||||
{
|
||||
App::I->install_render_debug_callback();
|
||||
const auto runtime_info_result = pp::renderer::gl::query_opengl_runtime_info(
|
||||
pp::legacy::gl_runtime::runtime_info_dispatch());
|
||||
if (runtime_info_result.ok())
|
||||
{
|
||||
const auto& runtime_info = runtime_info_result.value();
|
||||
LOG("GL version: %s", runtime_info.version);
|
||||
LOG("GL vendor: %s", runtime_info.vendor);
|
||||
LOG("GL renderer: %s", runtime_info.renderer);
|
||||
LOG("GLSL version: %s", runtime_info.shading_language_version);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("OpenGL runtime info failed: %s", runtime_info_result.status().message);
|
||||
}
|
||||
|
||||
//GLint n_exts;
|
||||
//glGetIntegerv(GL_NUM_EXTENSIONS, &n_exts);
|
||||
//for (int i = 0; i < n_exts; i++)
|
||||
//{
|
||||
// std::string ext = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
// //if (ext.find("debug") != std::string::npos)
|
||||
// {
|
||||
// LOG("%s", glGetStringi(GL_EXTENSIONS, i));
|
||||
// }
|
||||
//}
|
||||
|
||||
App::I->apply_render_platform_hints();
|
||||
const auto startup_state_status = pp::renderer::gl::apply_panopainter_initial_state(
|
||||
pp::renderer::gl::OpenGlStateDispatch {
|
||||
.enable = pp::legacy::ui_gl::enable_opengl_state,
|
||||
.disable = pp::legacy::ui_gl::disable_opengl_state,
|
||||
.blend_func = pp::legacy::ui_gl::set_opengl_blend_func,
|
||||
.blend_equation_separate = pp::legacy::ui_gl::set_opengl_blend_equation_separate,
|
||||
});
|
||||
if (!startup_state_status.ok())
|
||||
LOG("OpenGL startup state failed: %s", startup_state_status.message);
|
||||
});
|
||||
|
||||
const auto startup_preferences =
|
||||
pp::panopainter::read_legacy_startup_preferences(vr_controllers_enabled);
|
||||
const auto startup_plan = pp::app::plan_app_startup(
|
||||
startup_preferences.run_counter,
|
||||
startup_preferences.auto_timelapse,
|
||||
startup_preferences.vr_controllers_enabled,
|
||||
check_license());
|
||||
if (!startup_plan) {
|
||||
LOG("App startup plan failed: %s", startup_plan.status().message);
|
||||
} else {
|
||||
const auto persistence_status = pp::panopainter::execute_legacy_app_startup_persistence_plan(
|
||||
*this,
|
||||
startup_plan.value());
|
||||
if (!persistence_status.ok())
|
||||
LOG("App startup persistence failed: %s", persistence_status.message);
|
||||
}
|
||||
|
||||
const auto startup_resources = pp::app::plan_app_startup_resources(width, height);
|
||||
if (!startup_resources) {
|
||||
LOG("App startup resource plan failed: %s", startup_resources.status().message);
|
||||
} else {
|
||||
const auto resource_status = pp::panopainter::execute_legacy_app_startup_resources(
|
||||
*this,
|
||||
startup_resources.value());
|
||||
if (!resource_status.ok())
|
||||
LOG("App startup resources failed: %s", resource_status.message);
|
||||
}
|
||||
|
||||
if (startup_plan) {
|
||||
const auto startup_status = pp::panopainter::execute_legacy_app_startup_runtime_plan(
|
||||
*this,
|
||||
startup_plan.value());
|
||||
if (!startup_status.ok())
|
||||
LOG("App startup runtime execution failed: %s", startup_status.message);
|
||||
}
|
||||
pp::panopainter::execute_legacy_app_init(*this);
|
||||
}
|
||||
|
||||
void App::async_start()
|
||||
|
||||
Reference in New Issue
Block a user