Files
MapLibreParticleLab/include/mln/shaders/shader_program_base.hpp
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

48 lines
1.3 KiB
C++

#pragma once
#include <mln/gfx/shader.hpp>
#include <mln/gfx/vertex_attribute.hpp>
#include <mln/util/identity.hpp>
#include <string>
#include <optional>
namespace mln {
namespace gfx {
class ShaderProgramBase : public gfx::Shader {
protected:
ShaderProgramBase() {}
ShaderProgramBase(ShaderProgramBase&&) {}
~ShaderProgramBase() noexcept override = default;
template <typename T>
bool set(gfx::VertexAttributeArray& attrs, const size_t id, std::size_t i, T value) {
const auto& item = attrs.get(id);
if (item && i < item->getCount()) {
item->set(i, value);
return true;
}
return false;
}
public:
const util::SimpleIdentity& getID() const { return shaderProgramID; }
/// @brief Gets the sampler location
/// @param name uniform name
virtual std::optional<size_t> getSamplerLocation(const size_t) const = 0;
/// Get the available vertex attributes and their default values
virtual const gfx::VertexAttributeArray& getVertexAttributes() const = 0;
/// Get the available instance attributes and their default values
virtual const gfx::VertexAttributeArray& getInstanceAttributes() const = 0;
protected:
util::SimpleIdentity shaderProgramID;
};
} // namespace gfx
} // namespace mln