Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
Presentation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <SDL3/SDL.h>
4
5#include <cstdint>
6#include <expected>
7#include <span>
8#include <string>
9#include <string_view>
10#include <vector>
11
13{
20
21 enum class PresentMode
22 {
23 Vsync,
24 Mailbox,
26 };
27
37
38 [[nodiscard]] std::expected<Options, std::string>
39 parseArguments(std::span<const std::string_view> arguments);
40
42 const Options& options) noexcept;
43
44 [[nodiscard]] std::pair<int, int> initialWindowSize(
45 const Options& options) noexcept;
46
47 [[nodiscard]] std::expected<void, std::string>
48 configureWindow(SDL_Window* window, const Options& options);
49
50 // F11 convenience path: desktop-resolution borderless fullscreen <-> the
51 // configured development window size. It does not alter gameplay state.
52 [[nodiscard]] std::expected<void, std::string>
55 const Options& options);
56
58 PresentMode mode) noexcept;
59
60 [[nodiscard]] std::string_view presentModeName(
61 PresentMode mode) noexcept;
62
63 [[nodiscard]] std::string_view windowModeName(
64 WindowMode mode) noexcept;
65
66 // Applies the requested presentation mode after the SDL_GPU swapchain is
67 // created. Unsupported mailbox/immediate requests fall back to VSync.
68 [[nodiscard]] std::expected<SDL_GPUPresentMode, std::string>
70 SDL_GPUDevice* device,
73
74 // Lightweight runtime evidence for the modernization target. The title is
75 // refreshed roughly once per second with physical swapchain-scale pixels
76 // and measured submitted frames per second.
78 {
79 public:
80 explicit FrameTelemetry(SDL_Window* window) noexcept;
81 void framePresented() noexcept;
82 [[nodiscard]] double lastFramesPerSecond() const noexcept;
83
84 private:
85 SDL_Window* window_{};
86 Uint64 sampleStartNanoseconds_{};
87 std::uint32_t sampleFrames_{};
88 double lastFramesPerSecond_{};
89 };
90}
unsigned index
double lastFramesPerSecond() const noexcept
std::expected< Options, std::string > parseArguments(std::span< const std::string_view > arguments)
std::expected< void, std::string > configureWindow(SDL_Window *window, const Options &options)
std::string_view presentModeName(PresentMode mode) noexcept
std::string_view windowModeName(WindowMode mode) noexcept
std::expected< SDL_GPUPresentMode, std::string > configureSwapchain(SDL_GPUDevice *device, SDL_Window *window, PresentMode requested)
std::pair< int, int > initialWindowSize(const Options &options) noexcept
SDL_WindowFlags windowFlags(const Options &options) noexcept
SDL_GPUPresentMode toSDLPresentMode(PresentMode mode) noexcept
std::expected< void, std::string > toggleBorderlessFullscreen(SDL_Window *window, const Options &options)
std::vector< std::string_view > remaining