Started refactor to lazily compilable shaders.

This commit is contained in:
zy4n
2025-03-02 22:56:53 +01:00
parent 447146b7f5
commit 925125e99b
50 changed files with 2181 additions and 738 deletions

View File

@@ -2,83 +2,40 @@
#include "opengl/shader_program_variable.hpp"
#include <array>
#include "util/enum_bitfield_operators.hpp"
#include <string_view>
namespace shader_program::attributes::point_cloud
{
enum class flags : int {
enum class flags : unsigned {
none = 0,
position = 1 << 0,
normal = 1 << 1,
luminance = 1 << 2,
color = 1 << 2,
reflectance = 1 << 3
alpha = 1 << 3
};
constexpr inline auto position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 0 }, "vertex_position");
constexpr inline auto normal = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "vertex_normal");
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 2 }, "vertex_color");
constexpr inline auto reflectance = zgl::shader_program_variable({ GL_FLOAT, 2 }, "vertex_reflectance");
constexpr inline auto position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 0 }, "model_vertex_position");
constexpr inline auto normal = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_normal");
constexpr inline auto luminance = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_l");
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_rgb");
constexpr inline auto alpha = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "model_vertex_a");
constexpr inline auto all = std::array{
position, normal, color, reflectance
position, normal, luminance, color, alpha
};
constexpr inline auto names = std::array<std::string_view, 5>{
"position",
"normal",
"luminance",
"color",
"alpha"
};
}
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator|(
const shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b
) {
return static_cast<shader_program::attributes::point_cloud::flags>(static_cast<int>(a) | static_cast<int>(b));
}
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator&(
const shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b
) {
return static_cast<shader_program::attributes::point_cloud::flags>(static_cast<int>(a) & static_cast<int>(b));
}
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator^(
const shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b
) {
return static_cast<shader_program::attributes::point_cloud::flags>(static_cast<int>(a) ^ static_cast<int>(b));
}
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator~(const shader_program::attributes::point_cloud::flags& a) {
return static_cast<shader_program::attributes::point_cloud::flags>(~static_cast<int>(a));
}
constexpr shader_program::attributes::point_cloud::flags& operator|=(shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b) {
return a = a | b;
}
constexpr shader_program::attributes::point_cloud::flags& operator&=(shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b) {
return a = a & b;
}
constexpr shader_program::attributes::point_cloud::flags& operator^=(shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b) {
return a = a ^ b;
}
[[nodiscard]] constexpr bool operator<(
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
) {
return static_cast<int>(lhs) < static_cast<int>(rhs);
}
[[nodiscard]] constexpr bool operator<=(
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
) {
return static_cast<int>(lhs) <= static_cast<int>(rhs);
}
[[nodiscard]] constexpr bool operator>(
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
) {
return static_cast<int>(lhs) > static_cast<int>(rhs);
}
[[nodiscard]] constexpr bool operator>=(
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
) {
return static_cast<int>(lhs) >= static_cast<int>(rhs);
}
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::attributes::point_cloud::flags)