save state

This commit is contained in:
2026-01-16 16:34:32 +01:00
parent fbb6917812
commit a35c222570
15 changed files with 1052 additions and 266 deletions

View File

@@ -1,50 +1,62 @@
// Desktop platform implementation using GLFW + OpenGL 3.3
// Note: Graphics context and rendering is handled by RmlUi's backend.
// This platform implementation provides file interface and utilities.
// D:\Dev\Mosis\MosisService\designer\src\desktop_platform.h
#pragma once
#include "platform.h"
#include "file_interface.h"
#include <memory>
#include "desktop_file_interface.h"
namespace mosis::desktop {
// Forward declare GLFW types to avoid including glfw3.h here
struct GLFWwindow;
namespace mosis {
class DesktopPlatform : public IPlatform {
uint32_t m_width = 540;
uint32_t m_height = 960;
std::unique_ptr<DesktopFileInterface> m_file_interface;
double m_start_time = 0.0;
public:
DesktopPlatform();
~DesktopPlatform() override;
DesktopPlatform(GLFWwindow* window, uint32_t width, uint32_t height);
~DesktopPlatform() override = default;
// Initialize the platform
bool Initialize(uint32_t width, uint32_t height, const char* title);
void Shutdown();
// IPlatform implementation
// IPlatform interface
std::unique_ptr<IGraphicsContext> CreateGraphicsContext() override;
std::unique_ptr<IRenderTarget> CreateRenderTarget(uint32_t width, uint32_t height) override;
IFileInterface& GetFileInterface() override;
Rml::FileInterface& GetFileInterface() override;
void Log(const std::string& message) override;
void LogError(const std::string& message) override;
bool PollEvents() override;
void SwapBuffers() override;
bool ShouldClose() const override;
uint32_t GetWidth() const override { return m_width; }
uint32_t GetHeight() const override { return m_height; }
void SetResolution(uint32_t width, uint32_t height) override;
float GetDpiScale() const override;
double GetElapsedTime() const override;
// Desktop-specific
void SetAssetsPath(const std::string& path);
GLFWwindow* GetWindow() const { return m_window; }
// Input state (delegated to RmlUi backend)
bool IsMouseButtonDown() const;
void GetMousePosition(double& x, double& y) const;
private:
GLFWwindow* m_window;
uint32_t m_width;
uint32_t m_height;
DesktopFileInterface m_file_interface;
};
} // namespace mosis::desktop
// Desktop render target using FBO
class DesktopRenderTarget : public IRenderTarget {
public:
DesktopRenderTarget() = default;
~DesktopRenderTarget() override;
bool Create(uint32_t width, uint32_t height) override;
void Bind() override;
void Unbind() override;
void Destroy() override;
uint32_t GetFramebuffer() const override { return m_framebuffer; }
uint32_t GetTexture() const override { return m_texture; }
uint32_t GetWidth() const override { return m_width; }
uint32_t GetHeight() const override { return m_height; }
private:
uint32_t m_framebuffer = 0;
uint32_t m_texture = 0;
uint32_t m_depth_buffer = 0;
uint32_t m_width = 0;
uint32_t m_height = 0;
};
} // namespace mosis