Files
MapLibreParticleLab/include/mbgl/shaders/gl/shader_program_gl.hpp

67 lines
2.6 KiB
C++

#pragma once
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/uniform_block_gl.hpp>
#include <mbgl/gl/vertex_attribute_gl.hpp>
#include <mbgl/shaders/shader_source.hpp>
#include <mbgl/shaders/shader_program_base.hpp>
#include <mbgl/shaders/gl/shader_info.hpp>
#include <unordered_map>
namespace mbgl {
class ProgramParameters;
namespace gl {
class ShaderProgramGL final : public gfx::ShaderProgramBase {
public:
using SamplerLocationArray = std::array<std::optional<size_t>, shaders::maxTextureCountPerShader>;
ShaderProgramGL(UniqueProgram&& glProgram_);
ShaderProgramGL(UniqueProgram&&,
UniformBlockArrayGL&& uniformBlocks,
VertexAttributeArrayGL&& attributes,
SamplerLocationArray&& samplerLocations);
ShaderProgramGL(ShaderProgramGL&& other);
~ShaderProgramGL() noexcept override = default;
static constexpr std::string_view Name{"GenericGLShader"};
const std::string_view typeName() const noexcept override { return Name; }
static std::shared_ptr<ShaderProgramGL> create(Context&,
const ProgramParameters& programParameters,
const std::string_view firstAttribName,
const std::vector<shaders::UniformBlockInfo>& uniformBlocksInfo,
const std::vector<shaders::TextureInfo>& texturesInfo,
const std::vector<shaders::AttributeInfo>& attributesInfo,
const std::string& vertexSource,
const std::string& fragmentSource,
const std::string& additionalDefines = "") noexcept(false);
std::optional<size_t> getSamplerLocation(const size_t id) const override;
const gfx::UniformBlockArray& getUniformBlocks() const override { return uniformBlocks; }
const gfx::VertexAttributeArray& getVertexAttributes() const override { return vertexAttributes; }
const gfx::VertexAttributeArray& getInstanceAttributes() const override { return instanceAttributes; }
ProgramID getGLProgramID() const { return glProgram; }
protected:
gfx::UniformBlockArray& mutableUniformBlocks() override { return uniformBlocks; }
protected:
UniqueProgram glProgram;
UniformBlockArrayGL uniformBlocks;
VertexAttributeArrayGL vertexAttributes;
VertexAttributeArrayGL instanceAttributes;
SamplerLocationArray samplerLocations;
};
} // namespace gl
} // namespace mbgl