Started refactor to lazily compilable shaders.
This commit is contained in:
@@ -2,14 +2,15 @@
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace shader_program::uniforms::mesh
|
||||
{
|
||||
|
||||
enum class flags : int
|
||||
enum class flags : unsigned
|
||||
{
|
||||
none = 0,
|
||||
mvp = 1 << 0,
|
||||
mvp_matrix = 1 << 0,
|
||||
model_matrix = 1 << 1,
|
||||
point_size = 1 << 2,
|
||||
color = 1 << 3,
|
||||
@@ -21,27 +22,25 @@ enum class flags : int
|
||||
ambient_filter = 1 << 9,
|
||||
diffuse_filter = 1 << 10,
|
||||
specular_filter = 1 << 11,
|
||||
shininess = 1 << 12,
|
||||
alpha = 1 << 13
|
||||
shininess = 1 << 12
|
||||
};
|
||||
|
||||
constexpr inline auto mvp = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto mvp_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto model_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 1 }, "model_matrix");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 2 }, "point_size");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 3 }, "color");
|
||||
constexpr inline auto tex = zgl::shader_program_variable({ GL_SAMPLER_2D, 3 }, "tex");
|
||||
constexpr inline auto view_pos = zgl::shader_program_variable({ GL_FLOAT_VEC3, 4 }, "view_pos");
|
||||
constexpr inline auto point_light_direction = zgl::shader_program_variable({ GL_FLOAT_VEC3, 5 }, "point_light_direction");
|
||||
constexpr inline auto point_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 6 }, "point_light_color");
|
||||
constexpr inline auto ambient_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 7 }, "ambient_light_color");
|
||||
constexpr inline auto ambient_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 8 }, "ambient_filter");
|
||||
constexpr inline auto diffuse_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 9 }, "diffuse_filter");
|
||||
constexpr inline auto specular_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 10 }, "specular_filter");
|
||||
constexpr inline auto shininess = zgl::shader_program_variable({ GL_FLOAT, 11 }, "shininess");
|
||||
constexpr inline auto alpha = zgl::shader_program_variable({ GL_FLOAT, 12 }, "alpha");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 4 }, "color");
|
||||
constexpr inline auto view_pos = zgl::shader_program_variable({ GL_FLOAT_VEC3, 5 }, "view_pos");
|
||||
constexpr inline auto point_light_direction = zgl::shader_program_variable({ GL_FLOAT_VEC3, 6 }, "point_light_direction");
|
||||
constexpr inline auto point_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 7 }, "point_light_color");
|
||||
constexpr inline auto ambient_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 8 }, "ambient_light_color");
|
||||
constexpr inline auto ambient_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 9 }, "ambient_filter");
|
||||
constexpr inline auto diffuse_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 10 }, "diffuse_filter");
|
||||
constexpr inline auto specular_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 11 }, "specular_filter");
|
||||
constexpr inline auto shininess = zgl::shader_program_variable({ GL_FLOAT, 12 }, "shininess");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp,
|
||||
mvp_matrix,
|
||||
model_matrix,
|
||||
point_size,
|
||||
color,
|
||||
@@ -53,65 +52,24 @@ constexpr inline auto all = std::array{
|
||||
ambient_filter,
|
||||
diffuse_filter,
|
||||
specular_filter,
|
||||
shininess,
|
||||
alpha
|
||||
shininess
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"mvp_matrix",
|
||||
"model_matrix",
|
||||
"point_size",
|
||||
"color",
|
||||
"tex",
|
||||
"view_pos",
|
||||
"point_light_direction",
|
||||
"point_light_color",
|
||||
"ambient_light_color",
|
||||
"ambient_filter",
|
||||
"diffuse_filter",
|
||||
"specular_filter",
|
||||
"shininess"
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator|(
|
||||
const shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator&(
|
||||
const shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator^(
|
||||
const shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator~(const shader_program::uniforms::mesh::flags& a) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::mesh::flags& operator|=(shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::mesh::flags& operator&=(shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::mesh::flags& operator^=(shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::uniforms::mesh::flags)
|
||||
|
||||
@@ -6,92 +6,46 @@
|
||||
namespace shader_program::uniforms::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : int
|
||||
enum class flags : unsigned
|
||||
{
|
||||
none = 0,
|
||||
mvp = 1 << 0,
|
||||
mvp_matrix = 1 << 0,
|
||||
point_size = 1 << 1,
|
||||
color = 1 << 2,
|
||||
model = 1 << 3,
|
||||
model_matrix = 1 << 3,
|
||||
camera_position = 1 << 4,
|
||||
rainbow_offset_y = 1 << 5,
|
||||
rainbow_scale_y = 1 << 6,
|
||||
rainbow_scale_y = 1 << 6
|
||||
};
|
||||
|
||||
constexpr inline auto mvp = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 2 }, "point_size");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 3 }, "color");
|
||||
constexpr inline auto model = zgl::shader_program_variable({ GL_FLOAT_MAT4, 4 }, "model");
|
||||
constexpr inline auto camera_position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 5 }, "camera_position");
|
||||
constexpr inline auto rainbow_offset_y = zgl::shader_program_variable({ GL_FLOAT, 6 }, "rainbow_offset_y");
|
||||
constexpr inline auto rainbow_scale_y = zgl::shader_program_variable({ GL_FLOAT, 7 }, "rainbow_scale_y");
|
||||
constexpr inline auto mvp_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 1 }, "point_size");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 2 }, "color");
|
||||
constexpr inline auto model_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 3 }, "model_matrix");
|
||||
constexpr inline auto camera_position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 4 }, "camera_position");
|
||||
constexpr inline auto rainbow_offset_y = zgl::shader_program_variable({ GL_FLOAT, 5 }, "rainbow_offset_y");
|
||||
constexpr inline auto rainbow_scale_y = zgl::shader_program_variable({ GL_FLOAT, 6 }, "rainbow_scale_y");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp,
|
||||
mvp_matrix,
|
||||
point_size,
|
||||
color,
|
||||
model,
|
||||
model_matrix,
|
||||
camera_position,
|
||||
rainbow_offset_y,
|
||||
rainbow_scale_y
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"mvp_matrix",
|
||||
"point_size",
|
||||
"color",
|
||||
"model_matrix",
|
||||
"camera_position",
|
||||
"rainbow_offset_y",
|
||||
"rainbow_scale_y"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator|(
|
||||
const shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator&(
|
||||
const shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator^(
|
||||
const shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator~(const shader_program::uniforms::point_cloud::flags& a) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::point_cloud::flags& operator|=(shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::point_cloud::flags& operator&=(shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::point_cloud::flags& operator^=(shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::uniforms::point_cloud::flags)
|
||||
|
||||
Reference in New Issue
Block a user