Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
point_renderer.hpp
Go to the documentation of this file.
1#pragma once
2
44
45#include <cstddef>
46#include <memory>
47#include <span>
48#include <string>
49
50#include "orrery/core/types.hpp"
52#include "orrery/viz/gl_api.hpp"
55
56namespace orrery::viz {
57
59struct Colour {
60 float red = 1;
61 float green = 1;
62 float blue = 1;
63};
64
67 ToneMapping tone_mapping;
68
76 float point_size = 40;
77
84 float minimum_point_size = 1.5F;
85
93 float brightness = 1;
94
101 Colour cool{0.55F, 0.70F, 1.0F};
102 Colour warm{1.0F, 0.78F, 0.50F};
103};
104
107public:
115 PointRenderer(GlProcedureLoader loader, std::size_t width, std::size_t height);
116
118
119 // The class owns names allocated by the driver, so it is neither copyable
120 // nor movable. A moved-from renderer would have to hold zeroes that the
121 // destructor then asks the driver to delete, and OpenGL defines zero as a
122 // valid argument meaning "no object", so the mistake would be silent.
123 PointRenderer(const PointRenderer&) = delete;
124 PointRenderer& operator=(const PointRenderer&) = delete;
125 PointRenderer(PointRenderer&&) = delete;
126 PointRenderer& operator=(PointRenderer&&) = delete;
127
132 void resize(std::size_t width, std::size_t height);
133
134 [[nodiscard]] std::size_t width() const noexcept;
135 [[nodiscard]] std::size_t height() const noexcept;
136
142 void accumulate(core::Vec3Span<const core::Real> positions, std::span<const float> tints,
143 const Mat4& view_projection, const RenderSettings& settings);
144
152 void present(const RenderSettings& settings);
153
155 [[nodiscard]] std::size_t radiance_size() const noexcept;
156
165 void read_radiance(std::span<float> radiance) const;
166
169 [[nodiscard]] std::string device_description() const;
170
171private:
172 struct State;
173 std::unique_ptr<State> state_;
174};
175
176} // namespace orrery::viz
void resize(std::size_t width, std::size_t height)
Change the size of the accumulation target.
std::string device_description() const
What the driver calls itself, for the line a run prints about where its frames came from.
PointRenderer(GlProcedureLoader loader, std::size_t width, std::size_t height)
Build every OpenGL object the renderer needs, for a target of the given size.
void accumulate(core::Vec3Span< const core::Real > positions, std::span< const float > tints, const Mat4 &view_projection, const RenderSettings &settings)
Draw the particles into the accumulation target, replacing what was there.
void present(const RenderSettings &settings)
Tone map the accumulation target onto the default framebuffer, which is the window.
void read_radiance(std::span< float > radiance) const
Read the accumulated radiance back from the device.
std::size_t radiance_size() const noexcept
How many floats read_radiance needs, which is three per pixel.
The OpenGL entry points this renderer uses, and only those.
void(*(*)(const char *))() GlProcedureLoader
How a function is fetched from the driver.
Definition gl_api.hpp:97
The 4-by-4 transforms a camera needs, and nothing else.
A colour in linear light, before tone mapping.
Definition point_renderer.hpp:59
A 4-by-4 transform in column-major order.
Definition matrix4.hpp:58
Everything about how the picture looks that is not the camera.
Definition point_renderer.hpp:66
float minimum_point_size
The smallest a particle is allowed to become.
Definition point_renderer.hpp:84
Colour cool
The two ends of the colour ramp the per-particle tint selects between.
Definition point_renderer.hpp:101
float point_size
The diameter in pixels a particle would have one length unit from the camera, shrinking with distance...
Definition point_renderer.hpp:76
float brightness
The light one particle contributes at the centre of its sprite.
Definition point_renderer.hpp:93
The two numbers that decide how bright the picture is.
Definition tone_map.hpp:56
Turning accumulated light into pixels.
The scalar and index types that every layer of the project agrees on.
Three parallel component arrays, viewed as one sequence of 3-vectors.