opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
render_target.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <optional>
8#include <span>
9#include <utility>
10#include <vector>
11
12namespace osc
13{
15 public:
16 explicit RenderTarget() :
19 {
21 }
50
51 std::span<const RenderTargetColorAttachment> color_attachments() const { return colors_; }
52 const std::optional<RenderTargetDepthStencilAttachment>& depth_attachment() const { return depth_; }
53
54 // Returns the dimensions of this `RenderTarget` in physical pixels.
56 {
57 return depth_ ? depth_->buffer.pixel_dimensions() : colors_.front().buffer.pixel_dimensions();
58 }
59
60 // Returns the dimensions of this `RenderTarget` in device-independent pixels.
61 //
62 // The return value is equivalent to `pixel_dimensions() / device_pixel_ratio()`.
64
65 // Returns the ratio of the resolution of the texture in physical pixels
66 // to the resolution of it in device-independent pixels.
67 float device_pixel_ratio() const { return device_pixel_ratio_; }
68
69 // Sets the device-to-pixel ratio of this `RenderTarget, which has the effect
70 // of scaling the `dimensions()`.
72
73 void validate_or_throw() const;
74
75 private:
76 std::vector<RenderTargetColorAttachment> colors_;
77 std::optional<RenderTargetDepthStencilAttachment> depth_;
78 float device_pixel_ratio_ = 1.0f;
79 };
80}
Definition render_target.h:14
const std::optional< RenderTargetDepthStencilAttachment > & depth_attachment() const
Definition render_target.h:52
RenderTarget()
Definition render_target.h:16
float device_pixel_ratio() const
Definition render_target.h:67
Vector2i pixel_dimensions() const
Definition render_target.h:55
void set_device_pixel_ratio(float new_device_pixel_ratio)
Definition render_target.h:71
Vector2 dimensions() const
Definition render_target.h:63
RenderTarget(RenderTargetColorAttachment color0_attachment, RenderTargetColorAttachment color1_attachment, RenderTargetColorAttachment color2_attachment, RenderTargetDepthStencilAttachment depth_attachment)
Definition render_target.h:44
RenderTarget(RenderTargetColorAttachment color_attachment, RenderTargetDepthStencilAttachment depth_attachment)
Definition render_target.h:32
RenderTarget(RenderTargetColorAttachment color0_attachment, RenderTargetColorAttachment color1_attachment, RenderTargetDepthStencilAttachment depth_attachment)
Definition render_target.h:38
RenderTarget(RenderTargetDepthStencilAttachment depth_attachment)
Definition render_target.h:27
RenderTarget(RenderTargetColorAttachment color_attachment)
Definition render_target.h:22
std::span< const RenderTargetColorAttachment > color_attachments() const
Definition render_target.h:51
void validate_or_throw() const
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56
Definition render_target_color_attachment.h:10
Definition render_target_depth_stencil_attachment.h:9