44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "opengl/handles/shader_program_handle.hpp"
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
namespace zgl {
|
|
class shader_program_lookup
|
|
{
|
|
public:
|
|
void add(
|
|
const shader_program_handle& shader_program_handle,
|
|
std::span<const shader_uniform> all_attributes,
|
|
std::span<const shader_uniform> all_uniforms
|
|
);
|
|
|
|
[[nodiscard]] std::optional<shader_program_handle> find(
|
|
shader_program_handle::attribute_support_type attributes,
|
|
shader_program_handle::uniform_support_type uniforms,
|
|
std::span<const shader_uniform> all_attributes
|
|
) const;
|
|
|
|
void print();
|
|
|
|
private:
|
|
using attribute_locations_type = ztu::u32;
|
|
|
|
[[nodiscard]] static attribute_locations_type attribute_location_flags(
|
|
shader_program_handle::attribute_support_type attributes,
|
|
std::span<const shader_uniform> all_attributes
|
|
);
|
|
|
|
struct attribute_entry_type
|
|
{
|
|
shader_program_handle::attribute_support_type attributes;
|
|
attribute_locations_type locations; // Do not go past location 31!!!
|
|
};
|
|
|
|
std::vector<shader_program_handle::uniform_support_type> m_mesh_shader_program_uniforms;
|
|
std::vector<attribute_entry_type> m_mesh_shader_program_attributes;
|
|
std::vector<shader_program_handle> m_mesh_shader_programs;
|
|
};
|
|
}
|