Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
StudioEnvironmentGPU.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <SDL3/SDL_gpu.h>
4#include <cstdint>
5#include <expected>
6#include <filesystem>
7#include <span>
8#include <string>
9#include <vector>
10
11namespace monopoly::engine
12{
19 // MSTUDIO\0, six little-endian u32 fields: version, width, mip count,
20 // face count, format (1 = linear RGBA16F), payload size. Mip-major faces
21 // +X,-X,+Y,-Y,+Z,-Z; tightly packed rows, full chain, roughness=mip/(mips-1).
23 {
24 std::uint32_t width{};
25 std::uint32_t mipCount{};
26 std::vector<std::uint8_t> rgba16f;
27 };
28 [[nodiscard]] std::expected<StudioEnvironmentData, StudioEnvironmentError>
29 parseStudioEnvironment(std::span<const std::uint8_t> bytes);
30 [[nodiscard]] std::expected<StudioEnvironmentData, StudioEnvironmentError>
31 readStudioEnvironment(const std::filesystem::path& path);
32
34 {
35 public:
46 void reset() noexcept;
47 [[nodiscard]] SDL_GPUTexture* texture() const noexcept { return texture_; }
48 [[nodiscard]] SDL_GPUSampler* sampler() const noexcept { return sampler_; }
49 private:
50 [[nodiscard]] static std::expected<StudioEnvironmentGPU, StudioEnvironmentError>
51 uploadInternal(SDL_GPUDevice*, const StudioEnvironmentData&, bool fallback);
52 SDL_GPUDevice* device_{};
53 SDL_GPUTexture* texture_{};
54 SDL_GPUSampler* sampler_{};
55 };
56}
std::vector< std::byte > bytes
unsigned index
std::string path
static std::expected< StudioEnvironmentGPU, StudioEnvironmentError > upload(SDL_GPUDevice *, const StudioEnvironmentData &)
SDL_GPUTexture * texture() const noexcept
StudioEnvironmentGPU(const StudioEnvironmentGPU &)=delete
static std::expected< StudioEnvironmentGPU, StudioEnvironmentError > blackFallback(SDL_GPUDevice *)
SDL_GPUSampler * sampler() const noexcept
StudioEnvironmentGPU & operator=(const StudioEnvironmentGPU &)=delete
std::expected< StudioEnvironmentData, StudioEnvironmentError > readStudioEnvironment(const std::filesystem::path &path)
std::expected< StudioEnvironmentData, StudioEnvironmentError > parseStudioEnvironment(std::span< const std::uint8_t > bytes)