Own Linux platform services and narrow legacy fallback

This commit is contained in:
2026-06-17 15:32:29 +02:00
parent 3edb6617d0
commit 9750c418bc
9 changed files with 432 additions and 82 deletions

View File

@@ -43,6 +43,7 @@ add_executable(panopainter
../src/app_layout.cpp
../src/app_shaders.cpp
../src/app_vr.cpp
../src/platform_linux/linux_platform_services.cpp
../src/brush.cpp
../src/canvas.cpp
../src/canvas_layer.cpp

View File

@@ -3,42 +3,11 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <app.h>
#include <platform_legacy/legacy_platform_state.h>
#include <platform_legacy/legacy_platform_services.h>
#include <libgen.h>
#include <pwd.h>
#include <unistd.h>
#include <platform_linux/linux_platform_services.h>
static App app;
glm::vec2 g_cursor_pos;
int mkpath(const std::string& dir, mode_t mode = DEFFILEMODE)
{
struct stat sb;
if (dir.empty()) {
errno = EINVAL;
return 1;
}
if (!stat(dir.c_str(), &sb))
return 0;
mkpath(dirname(strdupa(dir.c_str())), mode);
int ret = mkdir(dir.c_str(), mode);
chmod(dir.c_str(), S_IRWXU);
if (ret != 0)
LOG("mkdir failed with error %d on %s", errno, dir.c_str());
return ret;
}
std::string linux_home_path()
{
struct passwd *pw = getpwuid(getuid());
return pw->pw_dir;
}
void error_log(int code, const char * s)
{
printf("glfw error: %s", s);
@@ -67,12 +36,10 @@ int main(int argc, char** args)
pp::platform::linux_desktop::set_fps_title_callback([wnd](std::string title) {
glfwSetWindowTitle(wnd, title.c_str());
});
auto platform_services = pp::platform::legacy::create_platform_services({
.glfw_shell = {
.acquire_render_context = [wnd] { glfwMakeContextCurrent(wnd); },
.present_render_context = [wnd] { glfwSwapBuffers(wnd); },
.request_app_close = [wnd] { glfwSetWindowShouldClose(wnd, GLFW_TRUE); },
},
auto platform_services = pp::platform::linux_desktop::create_platform_services({
.acquire_render_context = [wnd] { glfwMakeContextCurrent(wnd); },
.present_render_context = [wnd] { glfwSwapBuffers(wnd); },
.request_app_close = [wnd] { glfwSetWindowShouldClose(wnd, GLFW_TRUE); },
});
glfwSetCursorPosCallback(wnd, [](GLFWwindow* wnd, double x, double y){