Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
ColorTargetState.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "spdlog/fmt/fmt.h"
5#include "utils/webgpu.hpp"
6
7namespace Graphic::Utils {
9 public:
10 explicit ColorTargetState(const std::string &name) : _name(name) {}
11 ~ColorTargetState() override = default;
12
13 inline ColorTargetState &setFormat(wgpu::TextureFormat format)
14 {
15 this->_format = format;
16 return *this;
17 }
18
19 inline wgpu::TextureFormat getFormat(void) const { return this->_format; }
20
21 inline const wgpu::BlendState &getBlendState(void) const { return this->_blendState; }
22
23 inline ColorTargetState &setBlendState(const wgpu::BlendState &blendState)
24 {
25 this->_blendState = blendState;
26 return *this;
27 }
28
29 std::vector<ValidationError> validate(void) const override
30 {
31 std::vector<ValidationError> errors;
32 if (this->_format == wgpu::TextureFormat::Undefined)
33 {
34 errors.emplace_back("Format is not set", fmt::format("ColorTargetState({})", this->_name),
36 }
37 return errors;
38 }
39
40 private:
41 wgpu::TextureFormat _format = wgpu::TextureFormat::Undefined;
42 wgpu::BlendState _blendState{wgpu::Default};
43 std::string _name;
44};
45} // namespace Graphic::Utils
ColorTargetState & setFormat(wgpu::TextureFormat format)
Definition ColorTargetState.hpp:13
wgpu::TextureFormat _format
Definition ColorTargetState.hpp:41
std::vector< ValidationError > validate(void) const override
Definition ColorTargetState.hpp:29
std::string _name
Definition ColorTargetState.hpp:43
~ColorTargetState() override=default
const wgpu::BlendState & getBlendState(void) const
Definition ColorTargetState.hpp:21
wgpu::BlendState _blendState
Definition ColorTargetState.hpp:42
wgpu::TextureFormat getFormat(void) const
Definition ColorTargetState.hpp:19
ColorTargetState & setBlendState(const wgpu::BlendState &blendState)
Definition ColorTargetState.hpp:23
ColorTargetState(const std::string &name)
Definition ColorTargetState.hpp:10
Definition IValidable.hpp:26
Definition DefaultSampler.hpp:6
constexpr DefaultFlag Default
Definition webgpu.hpp:78
@ Error
Definition IValidable.hpp:14