ADD: Window mode system

This commit is contained in:
2025-12-15 22:22:56 +09:00
parent 5e7ad3fc78
commit b882d5e181
3 changed files with 247 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#include <vector>
#include <string>
#include <unordered_map>
#include <cstdint>
#include "vk_mem_alloc.h"
#include <deque>
#include <functional>
@@ -62,6 +63,13 @@ struct MeshNode : public Node
class VulkanEngine
{
public:
enum class WindowMode : uint8_t
{
Windowed = 0,
FullscreenDesktop = 1, // borderless fullscreen ("fullscreen windowed")
FullscreenExclusive = 2 // exclusive fullscreen (may change display mode)
};
bool _isInitialized{false};
int _frameNumber{0};
@@ -80,6 +88,9 @@ public:
struct SDL_Window *_window{nullptr};
WindowMode _windowMode{WindowMode::Windowed};
int _windowDisplayIndex{0};
FrameResources _frames[FRAME_OVERLAP];
FrameResources &get_current_frame() { return _frames[_frameNumber % FRAME_OVERLAP]; };
@@ -204,6 +215,9 @@ public:
//run main loop
void run();
// Window controls (runtime)
void set_window_mode(WindowMode mode, int display_index);
// Rendering resolution controls:
// - logicalRenderExtent controls camera aspect and picking (letterboxed view).
// - renderScale controls the internal render target pixel count (logical * scale).
@@ -258,6 +272,15 @@ public:
bool freeze_rendering{false};
private:
struct WindowedRect
{
int x{0};
int y{0};
int w{0};
int h{0};
bool valid{false};
} _windowedRect;
void init_frame_resources();
void init_pipelines();