Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
LightStore.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
7#include "./LightStore.hpp"
8
10#include "../rhi/GfxEnums.hpp"
11
12namespace esengine {
13
15 if (!device_) return;
16
17 if (ubo_ == BufferHandle::Invalid) {
18 ubo_ = device_->createBuffer(
19 {GfxBufferUsage::Uniform, static_cast<u32>(sizeof(LightConstants)), /*dynamic=*/true},
20 GfxContent::retained(), &data_);
21 dirty_ = false;
22 } else if (dirty_) {
23 device_->updateBuffer(ubo_, 0, &data_, sizeof(LightConstants));
24 dirty_ = false;
25 }
26 device_->setUniformBuffer(LIGHT_CONSTANTS_BINDING, ubo_);
27}
28
30 if (ubo_ != BufferHandle::Invalid && device_) {
31 device_->deleteBuffer(ubo_);
33 }
34 dirty_ = true;
35}
36
37} // namespace esengine
Abstract graphics device interface.
Backend-agnostic graphics enumerations.
Engine-side 2D light registry — the per-frame LightConstants UBO and its CPU mirror.
static constexpr GfxContent retained()
void free()
Frees the GPU UBO. Call while the device is still valid (RenderContext::shutdown).
constexpr u32 LIGHT_CONSTANTS_BINDING
Indexed UBO binding point for the per-frame LightConstants block.
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
CPU mirror of the GLSL LightConstants block (std140).