MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
example::MatrixRainBackdrop Class Reference

Public Member Functions

 MatrixRainBackdrop (PlanetWindow &window, const std::string &assetRoot, bool binaryGlyphMode, int fontSize, const std::string &fontPath, const std::string &color)
void onSwapchainAboutToRecreate ()
void onSwapchainRecreated (PlanetWindow &window)
void updateAndRender (PlanetWindow &window, VkCommandBuffer cmd)
 ~MatrixRainBackdrop ()

Detailed Description

Definition at line 31 of file planet.cpp.

Constructor & Destructor Documentation

◆ MatrixRainBackdrop()

example::MatrixRainBackdrop::MatrixRainBackdrop ( PlanetWindow & window,
const std::string & assetRoot,
bool binaryGlyphMode,
int fontSize,
const std::string & fontPath,
const std::string & color )

Definition at line 183 of file planet.cpp.

189 : rain([&]() {
190 matrix::RainConfig config = matrix::make_matrix_rain_config(assetRootPath, binaryGlyphMode);
193 if (binaryGlyphMode && fontPath.empty()) {
194 config.font_path = assetRootPath + "/data/binary.ttf";
195 }
196 config.font_size = std::max(1, fontSize);
197 if (!fontPath.empty()) {
198 config.font_path = fontPath;
199 }
200 config.color = color;
201 return std::make_unique<matrix::Rain>(window, std::move(config));
202 }()) {
203 lastFrame = Clock::now();
204 }
RainConfig make_matrix_rain_config(const std::string &asset_root, bool binary_glyph_mode)
Definition rain.cpp:157
std::string color
Definition rain.hpp:19
std::string font_path
Definition rain.hpp:18

◆ ~MatrixRainBackdrop()

example::MatrixRainBackdrop::~MatrixRainBackdrop ( )

Definition at line 206 of file planet.cpp.

206 {
207 }

Member Function Documentation

◆ onSwapchainAboutToRecreate()

void example::MatrixRainBackdrop::onSwapchainAboutToRecreate ( )

Definition at line 209 of file planet.cpp.

209 {
210 }

◆ onSwapchainRecreated()

void example::MatrixRainBackdrop::onSwapchainRecreated ( PlanetWindow & window)

Definition at line 212 of file planet.cpp.

212 {
213 if (rain) {
214 rain->resize(window);
215 }
216 }

◆ updateAndRender()

void example::MatrixRainBackdrop::updateAndRender ( PlanetWindow & window,
VkCommandBuffer cmd )

Definition at line 218 of file planet.cpp.

218 {
219 const auto now = Clock::now();
220 float dt = std::chrono::duration<float>(now - lastFrame).count();
221 lastFrame = now;
222 dt = std::clamp(dt, 0.0f, 1.0f / 15.0f);
223
224 if (rain == nullptr) {
225 return;
226 }
227
228 rain->resize(window);
229 rain->update(dt);
230 const VkExtent2D extent = window.getSwapchainExtent();
231 rain->render(static_cast<int>(extent.width), static_cast<int>(extent.height));
232 if (rain->sprite() != nullptr) {
233 window.renderBackgroundSprite(*rain->sprite(), cmd);
234 rain->sprite()->clearQueue();
235 }
236 }

The documentation for this class was generated from the following file: