Files

37 lines
1.1 KiB
C++

#pragma once
#include <cstddef>
#include <cstdint>
#include <expected>
#include <span>
#include <vector>
namespace evo::render {
inline constexpr std::size_t max_rectangles = 4096;
struct Color {
std::uint8_t red{}, green{}, blue{}, alpha{255};
};
struct Rectangle {
float x{}, y{}, width{}, height{};
Color color;
};
enum class FrameError : std::uint8_t { too_many_primitives, invalid_geometry };
// Owns copied logical-window coordinates; never stores simulation/native handles.
class Frame {
public:
[[nodiscard]] static std::expected<Frame, FrameError>
create(std::span<const Rectangle> rectangles, Color background = {});
[[nodiscard]] std::span<const Rectangle> rectangles() const noexcept {
return rectangles_;
}
[[nodiscard]] Color background() const noexcept {
return background_;
}
private:
Frame(std::span<const Rectangle> rectangles, Color background)
: rectangles_(rectangles.begin(), rectangles.end()), background_{background} {}
std::vector<Rectangle> rectangles_;
Color background_;
};
} // namespace evo::render