Started refactor to lazily compilable shaders.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <tuple>
|
||||
#include "../dynamic_read_buffers"
|
||||
#include "assets/data/surface_properties.hpp"
|
||||
#include "util/enum_operators.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace components::material
|
||||
{
|
||||
@@ -56,4 +56,4 @@ constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace material_component
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::material::flags)
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(components::material::flags)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_operators.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace components::mesh_vertex {
|
||||
|
||||
@@ -36,4 +36,4 @@ constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::mesh_vertex
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::mesh_vertex::flags)
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(components::mesh_vertex::flags)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_operators.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace components::point_cloud_vertex {
|
||||
|
||||
@@ -33,4 +33,4 @@ constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::point_cloud_vertex
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::point_cloud_vertex::flags)
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(components::point_cloud_vertex::flags)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <tuple>
|
||||
#include <cinttypes>
|
||||
#include "util/enum_operators.hpp"
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
|
||||
namespace components::texture {
|
||||
|
||||
@@ -25,4 +25,4 @@ constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::texture
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::texture::flags)
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(components::texture::flags)
|
||||
@@ -24,7 +24,7 @@ struct glsl_loader
|
||||
dynamic_shader_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
@@ -26,7 +26,7 @@ struct kitti_loader
|
||||
dynamic_point_cloud_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ struct kitti_pose_loader
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ struct mtl_loader
|
||||
dynamic_material_library_buffer& material_library_buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ struct obj_loader {
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
@@ -76,7 +76,7 @@ protected:
|
||||
std::set<indexed_vertex_type>& vertex_ids,
|
||||
std::ifstream& in,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic
|
||||
);
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ struct stl_loader {
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ struct threedtk_pose_loader
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
dynamic_shader_source_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
#include "dynamic_data_stores/dynamic_pose_store.hpp"
|
||||
#include "dynamic_data_stores/dynamic_shader_store.hpp"
|
||||
#include "dynamic_data_stores/dynamic_shader_source_store.hpp"
|
||||
#include "dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
|
||||
struct dynamic_data_store
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_shader_buffer.hpp"
|
||||
|
||||
// TODO use compressed store where all shaders are condensed into one vector
|
||||
using dynamic_shader_source_store = generic_dynamic_store<dynamic_shader_buffer>;
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
class dynamic_shader_store {
|
||||
|
||||
|
||||
};
|
||||
204
include/opengl/data_uploaders/shader_compiler.hpp
Normal file
204
include/opengl/data_uploaders/shader_compiler.hpp
Normal file
@@ -0,0 +1,204 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <bit>
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
#include <bits/ranges_algo.h>
|
||||
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_source_store.hpp"
|
||||
#include "opengl/shader_program_lookup.hpp"
|
||||
#include "opengl/handles/shader_handle.hpp"
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "shader_program/metadata_type.hpp"
|
||||
#include "shader_program/features/mesh_features.hpp"
|
||||
#include "shader_program/features/point_cloud_features.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "shader_program/metadata_type.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
class shader_program_compiler
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
// compile shader programs for given requirements
|
||||
// cache shader programs with their capabilities
|
||||
// store sstream for creating defines
|
||||
|
||||
// register shader source code
|
||||
// store define types for these shaders as bitmap
|
||||
void register_shader_sources(
|
||||
const dynamic_shader_source_store& shader_sources
|
||||
);
|
||||
|
||||
void compile_shaders(
|
||||
const dynamic_shader_source_store& shader_sources,
|
||||
std::span<const shader_program::metadata_type> required_capabilities,
|
||||
std::vector<shader_handle>& shader_handles
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
void tokenize_declarations(
|
||||
std::string_view source,
|
||||
std::vector<std::string_view> tokens,
|
||||
std::vector<std::size_t> declaration_token_counts,
|
||||
std::span<std::size_t> declaration_type_indices
|
||||
);
|
||||
|
||||
std::optional<shader_program::metadata_type> parse_metadata_from_tokens(
|
||||
std::span<const std::string_view> tokens,
|
||||
std::span<const std::size_t> declaration_token_counts,
|
||||
std::span<const std::size_t> declaration_type_indices
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_stage_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_geometry_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_features_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
[[nodiscard]] static bool parse_feature_toggles_declaration(
|
||||
std::span<const std::string_view> tokens,
|
||||
shader_program::metadata_type& metadata
|
||||
);
|
||||
|
||||
template<typename T>
|
||||
static void parse_feature_tokens(
|
||||
std::span<const std::string_view> tokens,
|
||||
const ztu::string_lookup<T>& feature_lookup,
|
||||
T& features
|
||||
);
|
||||
|
||||
std::optional<dynamic_shader_source_store::id_type> zgl::shader_program_compiler::find_compatible_shader_source(
|
||||
shader_program::metadata_type& requirements
|
||||
);
|
||||
|
||||
template<typename T>
|
||||
void add_required_feature_defines(
|
||||
T toggle_flags,
|
||||
std::span<const std::string> defines,
|
||||
std::vector<const char*>& shader_strings
|
||||
);
|
||||
|
||||
private:
|
||||
enum class metadata_declaration_type : std::size_t
|
||||
{
|
||||
stage = 0,
|
||||
geometry = 1,
|
||||
features = 2,
|
||||
feature_toggles = 3,
|
||||
invalid = std::numeric_limits<std::size_t>::max()
|
||||
};
|
||||
|
||||
inline static auto declaration_lookup = ztu::string_lookup<metadata_declaration_type>{
|
||||
{ "STAGE", metadata_declaration_type::stage },
|
||||
{ "GEOMETRY", metadata_declaration_type::geometry },
|
||||
{ "FEATURES", metadata_declaration_type::features },
|
||||
{ "FEATURE_TOGGLES", metadata_declaration_type::feature_toggles }
|
||||
};
|
||||
|
||||
inline static auto stage_lookup = ztu::string_lookup<shader_program::stages>{
|
||||
{ "VERTEX", shader_program::stages::vertex },
|
||||
{ "GEOMETRY", shader_program::stages::geometry },
|
||||
{ "FRAGMENT", shader_program::stages::fragment },
|
||||
};
|
||||
|
||||
inline static auto geometry_lookup = ztu::string_lookup<shader_program::geometries>{
|
||||
{ "MESH", shader_program::geometries::mesh },
|
||||
{ "POINT_CLOUD", shader_program::geometries::point_cloud }
|
||||
};
|
||||
|
||||
inline static auto mesh_feature_lookup = []
|
||||
{
|
||||
using namespace shader_program::features::mesh;
|
||||
|
||||
auto lookup = ztu::string_lookup<flags>{};
|
||||
lookup.reserve(all.size());
|
||||
|
||||
constexpr auto all_flags = std::array{
|
||||
flags::face, flags::line, flags::point,
|
||||
flags::luminance, flags::color, flags::alpha,
|
||||
flags::lighting, flags::texture, flags::uniform_color
|
||||
};
|
||||
|
||||
for (const auto& [ define, flag ] : std::ranges::views::zip(defines, all_flags))
|
||||
{
|
||||
lookup.emplace(std::string(define), flag);
|
||||
}
|
||||
|
||||
return lookup;
|
||||
}();
|
||||
|
||||
inline static auto point_cloud_feature_lookup = []
|
||||
{
|
||||
using namespace shader_program::features::point_cloud;
|
||||
|
||||
auto lookup = ztu::string_lookup<flags>{};
|
||||
lookup.reserve(all.size());
|
||||
|
||||
constexpr auto all_flags = std::array{
|
||||
flags::square, flags::lighting, flags::luminance,
|
||||
flags::color, flags::alpha, flags::uniform_color,
|
||||
flags::rainbow
|
||||
};
|
||||
|
||||
for (const auto& [ define, flag ] : std::ranges::views::zip(defines, all_flags))
|
||||
{
|
||||
lookup.emplace(std::string(define), flag);
|
||||
}
|
||||
|
||||
return lookup;
|
||||
}();
|
||||
|
||||
inline static auto mesh_feature_defines = []
|
||||
{
|
||||
using namespace shader_program::features::mesh;
|
||||
|
||||
auto statements = std::array<std::string, all.size()>{};
|
||||
|
||||
std::ranges::transform(
|
||||
defines,
|
||||
statements.begin(),
|
||||
[](const auto& name) {
|
||||
return std::format("#define {}\n", name);
|
||||
}
|
||||
);
|
||||
|
||||
return statements;
|
||||
}();
|
||||
|
||||
inline static auto point_cloud_feature_defines = []
|
||||
{
|
||||
using namespace shader_program::features::point_cloud;
|
||||
|
||||
auto statements = std::array<std::string, all.size()>{};
|
||||
|
||||
std::ranges::transform(
|
||||
defines,
|
||||
statements.begin(),
|
||||
[](const auto& name) {
|
||||
return std::format("#define {}\n", name);
|
||||
}
|
||||
);
|
||||
|
||||
return statements;
|
||||
}();
|
||||
|
||||
|
||||
std::vector<std::pair<shader_program::metadata_type, dynamic_shader_source_store::id_type>> shader_lookup;
|
||||
};
|
||||
}
|
||||
42
include/opengl/data_uploaders/shader_program_compiler.hpp
Normal file
42
include/opengl/data_uploaders/shader_program_compiler.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_source_store.hpp"
|
||||
#include "opengl/shader_program_lookup.hpp"
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
|
||||
template<typename Capabilities>
|
||||
class shader_program_compiler
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// compile shader programs for given requirements
|
||||
// cache shader programs with their capabilities
|
||||
// store sstream for creating defines
|
||||
|
||||
// register shader source code
|
||||
// store define types for these shaders as bitmap
|
||||
void register_shader_sources(
|
||||
const dynamic_shader_source_store& shader_sources
|
||||
);
|
||||
|
||||
void find_or_compile_shader_programs(
|
||||
std::span<const Capabilities> required_capabilities,
|
||||
zgl::shader_program_lookup& shader_program_lookup
|
||||
);
|
||||
|
||||
|
||||
// create metadata for all sources
|
||||
|
||||
// get
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::unordered_map<dynamic_shader_source_store::id_type, Capabilities> shader_capabilities;
|
||||
|
||||
};
|
||||
@@ -16,52 +16,42 @@ class texture_data_uploader
|
||||
) {
|
||||
|
||||
std::vector<GLuint> texture_ids;
|
||||
std::vector<GLuint> invalid_texture_ids;
|
||||
|
||||
texture_ids.resize(dynamic_data.size());
|
||||
|
||||
glGenTextures(texture_ids.size(), texture_ids.data());
|
||||
|
||||
auto texture_id_it = texture_ids.begin();
|
||||
|
||||
for (std::size_t i{}; i != dynamic_data.size(); ++i)
|
||||
{
|
||||
const auto& texture_id = *texture_id_it;
|
||||
const auto& texture = dynamic_data[i];
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture_id);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
GLenum format;
|
||||
switch (texture.components()) {
|
||||
using enum components::texture::flags;
|
||||
case luminance:
|
||||
format = GL_LUMINANCE;
|
||||
break;
|
||||
case luminance | alpha:
|
||||
format = GL_LUMINANCE_ALPHA;
|
||||
break;
|
||||
case red | green | blue:
|
||||
format = GL_RGB;
|
||||
break;
|
||||
case red | green | blue | alpha:
|
||||
format = GL_RGBA;
|
||||
break;
|
||||
default:
|
||||
format = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (format == GL_INVALID_ENUM)
|
||||
{
|
||||
invalid_texture_ids.push_back(texture_id);
|
||||
}
|
||||
else
|
||||
const auto invalid_texture_ids = std::ranges::partition(
|
||||
texture_ids,
|
||||
[](GLuint texture_id)
|
||||
{
|
||||
GLenum format;
|
||||
switch (texture.components()) {
|
||||
using enum components::texture::flags;
|
||||
case luminance:
|
||||
format = GL_LUMINANCE;
|
||||
break;
|
||||
case luminance | alpha:
|
||||
format = GL_LUMINANCE_ALPHA;
|
||||
break;
|
||||
case red | green | blue:
|
||||
format = GL_RGB;
|
||||
break;
|
||||
case red | green | blue | alpha:
|
||||
format = GL_RGBA;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture_id);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0,
|
||||
GL_RGBA8,
|
||||
@@ -73,12 +63,16 @@ class texture_data_uploader
|
||||
texture.data()
|
||||
);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glDeleteTextures(invalid_texture_ids.size(), invalid_texture_ids.data());
|
||||
|
||||
invalid_texture_ids.resize(texture_ids.size() - invalid_texture_ids.size());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "shader_program/capabilities/mesh_capabilities.hpp"
|
||||
#include "shader_program/features/mesh_features.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "shader_program/capabilities/point_cloud_capabilities.hpp"
|
||||
#include "shader_program/features/point_cloud_features.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
@@ -2,82 +2,42 @@
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
#include "util/enum_bitfield_operators.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace shader_program::attributes::mesh
|
||||
{
|
||||
|
||||
enum class flags : int {
|
||||
enum class flags : unsigned {
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
tex_coord = 1 << 2
|
||||
luminance = 1 << 2,
|
||||
color = 1 << 3,
|
||||
alpha = 1 << 4,
|
||||
tex_coord = 1 << 5
|
||||
};
|
||||
|
||||
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 tex_coord = zgl::shader_program_variable({ GL_FLOAT_VEC2, 2 }, "vertex_tex_coord");
|
||||
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, 2 }, "model_vertex_l");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 2 }, "model_vertex_rgb");
|
||||
constexpr inline auto alpha = zgl::shader_program_variable({ GL_FLOAT, 3 }, "model_vertex_a");
|
||||
constexpr inline auto tex_coord = zgl::shader_program_variable({ GL_FLOAT_VEC2, 2 }, "model_vertex_tex_coord");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, tex_coord
|
||||
position, normal, luminance, color, alpha, tex_coord
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 6>{
|
||||
"position",
|
||||
"normal",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"tex_coord"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator|(
|
||||
const shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator&(
|
||||
const shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator^(
|
||||
const shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator~(const shader_program::attributes::mesh::flags& a) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::mesh::flags& operator|=(shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::mesh::flags& operator&=(shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::mesh::flags& operator^=(shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
DEFINE_ENUM_BITFIELD_OPERATORS(shader_program::attributes::mesh::flags)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "shader_program/attributes/mesh_attributes.hpp"
|
||||
#include "shader_program/uniforms/mesh_uniforms.hpp"
|
||||
|
||||
namespace shader_program::capabilities::mesh
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::mesh::flags attributes{
|
||||
attributes::mesh::flags::none
|
||||
};
|
||||
uniforms::mesh::flags uniforms{
|
||||
uniforms::mesh::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type position = 0;
|
||||
constexpr inline type lit = 1;
|
||||
constexpr inline type textured = 2;
|
||||
constexpr inline type uniform_color = 3;
|
||||
constexpr inline type uniform_alpha = 4;
|
||||
constexpr inline type point = 5;
|
||||
}
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
lit = 1 << indices::lit,
|
||||
textured = 1 << indices::textured,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
uniform_alpha = 1 << indices::uniform_alpha,
|
||||
point = 1 << indices::point
|
||||
};
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = uniforms::mesh::flags::mvp
|
||||
};
|
||||
|
||||
constexpr inline auto lit = type{
|
||||
.attributes = attributes::mesh::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::mesh::flags::model_matrix |
|
||||
uniforms::mesh::flags::view_pos |
|
||||
uniforms::mesh::flags::point_light_direction |
|
||||
uniforms::mesh::flags::point_light_color |
|
||||
uniforms::mesh::flags::ambient_light_color |
|
||||
uniforms::mesh::flags::ambient_filter |
|
||||
uniforms::mesh::flags::diffuse_filter |
|
||||
uniforms::mesh::flags::specular_filter |
|
||||
uniforms::mesh::flags::shininess
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto point = type{
|
||||
.uniforms = uniforms::mesh::flags::point_size
|
||||
};
|
||||
|
||||
constexpr inline auto textured = type{
|
||||
.attributes = attributes::mesh::flags::tex_coord,
|
||||
.uniforms = uniforms::mesh::flags::tex
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::mesh::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_alpha = type{
|
||||
.uniforms = uniforms::mesh::flags::alpha
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, lit, textured, uniform_color, uniform_alpha, point
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "shader_program/attributes/point_cloud_attributes.hpp"
|
||||
#include "shader_program/uniforms/point_cloud_uniforms.hpp"
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::capabilities::point_cloud
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::point_cloud::flags attributes{
|
||||
attributes::point_cloud::flags::none
|
||||
};
|
||||
uniforms::point_cloud::flags uniforms{
|
||||
uniforms::point_cloud::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type position = 0;
|
||||
constexpr inline type vertex_color = 1;
|
||||
constexpr inline type uniform_color = 2;
|
||||
constexpr inline type normal = 3;
|
||||
constexpr inline type reflectance = 4;
|
||||
constexpr inline type rainbow = 5;
|
||||
}
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
vertex_color = 1 << indices::vertex_color,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
normal = 1 << indices::normal,
|
||||
reflectance = 1 << indices::reflectance,
|
||||
rainbow = 1 << indices::rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.attributes = attributes::point_cloud::flags::position,
|
||||
.uniforms = uniforms::point_cloud::flags::mvp
|
||||
};
|
||||
|
||||
constexpr inline auto rainbow = type{};
|
||||
|
||||
constexpr inline auto vertex_color = type{
|
||||
.attributes = attributes::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto normal = type{
|
||||
.attributes = attributes::point_cloud::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::model |
|
||||
uniforms::point_cloud::flags::camera_position
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto reflectance = type{
|
||||
.attributes = attributes::point_cloud::flags::reflectance
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, vertex_color, uniform_color, normal, reflectance, rainbow
|
||||
};
|
||||
|
||||
}
|
||||
134
include/shader_program/features/mesh_features.hpp
Normal file
134
include/shader_program/features/mesh_features.hpp
Normal file
@@ -0,0 +1,134 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "shader_program/attributes/mesh_attributes.hpp"
|
||||
#include "shader_program/uniforms/mesh_uniforms.hpp"
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace shader_program::features::mesh
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::mesh::flags attributes{
|
||||
attributes::mesh::flags::none
|
||||
};
|
||||
uniforms::mesh::flags uniforms{
|
||||
uniforms::mesh::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type face = 0;
|
||||
constexpr inline type line = 1;
|
||||
constexpr inline type point = 2;
|
||||
constexpr inline type luminance = 3;
|
||||
constexpr inline type color = 4;
|
||||
constexpr inline type alpha = 5;
|
||||
constexpr inline type lighting = 6;
|
||||
constexpr inline type texture = 7;
|
||||
constexpr inline type uniform_color = 8;
|
||||
}
|
||||
|
||||
enum class flags : unsigned
|
||||
{
|
||||
none = 0,
|
||||
face = 1 << indices::face,
|
||||
line = 1 << indices::line,
|
||||
point = 1 << indices::point,
|
||||
luminance = 1 << indices::luminance,
|
||||
color = 1 << indices::color,
|
||||
alpha = 1 << indices::alpha,
|
||||
lighting = 1 << indices::lighting,
|
||||
texture = 1 << indices::texture,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
};
|
||||
|
||||
constexpr inline auto face = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = uniforms::mesh::flags::mvp_matrix
|
||||
};
|
||||
|
||||
constexpr inline auto line = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = uniforms::mesh::flags::mvp_matrix
|
||||
};
|
||||
|
||||
constexpr inline auto point = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = (
|
||||
uniforms::mesh::flags::mvp_matrix |
|
||||
uniforms::mesh::flags::point_size
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto luminance = type{
|
||||
.attributes = attributes::mesh::flags::luminance
|
||||
};
|
||||
|
||||
constexpr inline auto color = type{
|
||||
.attributes = attributes::mesh::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto alpha = type{
|
||||
.attributes = attributes::mesh::flags::alpha
|
||||
};
|
||||
|
||||
constexpr inline auto lighting = type{
|
||||
.attributes = attributes::mesh::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::mesh::flags::model_matrix |
|
||||
uniforms::mesh::flags::view_pos |
|
||||
uniforms::mesh::flags::point_light_direction |
|
||||
uniforms::mesh::flags::point_light_color |
|
||||
uniforms::mesh::flags::ambient_light_color |
|
||||
uniforms::mesh::flags::ambient_filter |
|
||||
uniforms::mesh::flags::diffuse_filter |
|
||||
uniforms::mesh::flags::specular_filter |
|
||||
uniforms::mesh::flags::shininess
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto texture = type{
|
||||
.attributes = attributes::mesh::flags::tex_coord,
|
||||
.uniforms = uniforms::mesh::flags::tex
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::mesh::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
face, line, point, luminance, color, alpha, lighting, texture, uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array<std::string_view, 9>{
|
||||
"face",
|
||||
"line",
|
||||
"point",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"lighting",
|
||||
"texture",
|
||||
"uniform_color"
|
||||
};
|
||||
|
||||
constexpr inline auto defines = std::array<std::string_view, 9>{
|
||||
"FACE",
|
||||
"LINE",
|
||||
"POINT",
|
||||
"V_L",
|
||||
"V_RGB",
|
||||
"V_A",
|
||||
"LIGHTING",
|
||||
"TEXTURE",
|
||||
"U_RGBA"
|
||||
};
|
||||
|
||||
}
|
||||
112
include/shader_program/features/point_cloud_features.hpp
Normal file
112
include/shader_program/features/point_cloud_features.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
#include "shader_program/attributes/point_cloud_attributes.hpp"
|
||||
#include "shader_program/uniforms/point_cloud_uniforms.hpp"
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::features::point_cloud
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::point_cloud::flags attributes{
|
||||
attributes::point_cloud::flags::none
|
||||
};
|
||||
uniforms::point_cloud::flags uniforms{
|
||||
uniforms::point_cloud::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type square = 0;
|
||||
constexpr inline type lighting = 1;
|
||||
constexpr inline type luminance = 2;
|
||||
constexpr inline type color = 3;
|
||||
constexpr inline type alpha = 4;
|
||||
constexpr inline type uniform_color = 5;
|
||||
constexpr inline type rainbow = 6;
|
||||
}
|
||||
|
||||
enum class flags : unsigned
|
||||
{
|
||||
none = 0,
|
||||
square = 1 << indices::square,
|
||||
lighting = 1 << indices::lighting,
|
||||
luminance = 1 << indices::luminance,
|
||||
color = 1 << indices::color,
|
||||
alpha = 1 << indices::alpha,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
rainbow = 1 << indices::rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto square = type{
|
||||
.attributes = attributes::point_cloud::flags::position,
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::mvp_matrix |
|
||||
uniforms::point_cloud::flags::point_size
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto lighting = type{
|
||||
.attributes = attributes::point_cloud::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::model_matrix |
|
||||
uniforms::point_cloud::flags::camera_position
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto luminance = type{
|
||||
.attributes = attributes::point_cloud::flags::luminance
|
||||
};
|
||||
|
||||
constexpr inline auto color = type{
|
||||
.attributes = attributes::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto alpha = type{
|
||||
.attributes = attributes::point_cloud::flags::alpha
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto rainbow = type{
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::rainbow_offset_y |
|
||||
uniforms::point_cloud::flags::rainbow_scale_y
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
square, lighting, luminance, color, alpha, uniform_color, rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto names = std::array{
|
||||
"square",
|
||||
"lighting",
|
||||
"luminance",
|
||||
"color",
|
||||
"alpha",
|
||||
"uniform_color",
|
||||
"rainbow"
|
||||
};
|
||||
|
||||
constexpr inline auto defines = std::array{
|
||||
"SQUARE",
|
||||
"LIGHTING",
|
||||
"V_L",
|
||||
"V_RGB",
|
||||
"V_A",
|
||||
"U_RGBA",
|
||||
"RAINBOW"
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
219
include/shader_program/metadata_type.hpp
Normal file
219
include/shader_program/metadata_type.hpp
Normal file
@@ -0,0 +1,219 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "features/mesh_features.hpp"
|
||||
#include "features/point_cloud_features.hpp"
|
||||
|
||||
namespace shader_program
|
||||
{
|
||||
|
||||
enum class geometries : int
|
||||
{
|
||||
mesh = 0,
|
||||
point_cloud = 1
|
||||
};
|
||||
|
||||
enum class stages : GLenum
|
||||
{
|
||||
vertex = GL_VERTEX_SHADER,
|
||||
geometry = GL_GEOMETRY_SHADER,
|
||||
fragment = GL_FRAGMENT_SHADER
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
union combined_feature_type
|
||||
{
|
||||
features::mesh::flags mesh;
|
||||
features::point_cloud::flags point_cloud;
|
||||
|
||||
using generic_type = std::common_type_t<
|
||||
std::underlying_type_t<features::mesh::flags>,
|
||||
std::underlying_type_t<features::point_cloud::flags>
|
||||
>;
|
||||
|
||||
generic_type generic(const geometries geometry) const noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
return static_cast<generic_type>(mesh);
|
||||
case geometries::point_cloud:
|
||||
return static_cast<generic_type>(point_cloud);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
void from_generic(
|
||||
const geometries geometry,
|
||||
generic_type new_features
|
||||
) noexcept {
|
||||
switch (geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
mesh = static_cast<features::mesh::flags>(new_features);
|
||||
case geometries::point_cloud:
|
||||
point_cloud = static_cast<features::point_cloud::flags>(new_features);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct metadata_type
|
||||
{
|
||||
geometries geometry;
|
||||
stages stage;
|
||||
combined_feature_type features;
|
||||
combined_feature_type feature_toggles;
|
||||
|
||||
std::pair<combined_feature_type::generic_type, combined_feature_type::generic_type> generic() const noexcept
|
||||
{
|
||||
switch (geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
return {
|
||||
static_cast<combined_feature_type::generic_type>(features.mesh),
|
||||
static_cast<combined_feature_type::generic_type>(feature_toggles.mesh)
|
||||
};
|
||||
case geometries::point_cloud:
|
||||
return {
|
||||
static_cast<combined_feature_type::generic_type>(features.point_cloud),
|
||||
static_cast<combined_feature_type::generic_type>(feature_toggles.point_cloud)
|
||||
};
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
void from_generic(
|
||||
combined_feature_type::generic_type new_features,
|
||||
combined_feature_type::generic_type new_feature_toggles
|
||||
) noexcept {
|
||||
switch (geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
features.mesh = static_cast<features::mesh::flags>(new_features);
|
||||
feature_toggles.mesh = static_cast<features::mesh::flags>(new_feature_toggles);
|
||||
case geometries::point_cloud:
|
||||
features.point_cloud = static_cast<features::point_cloud::flags>(new_features);
|
||||
feature_toggles.point_cloud = static_cast<features::point_cloud::flags>(new_feature_toggles);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
auto operator<=>(const metadata_type& other) const noexcept
|
||||
{
|
||||
if (this->geometry == other.geometry)
|
||||
{
|
||||
switch (this->geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
return (
|
||||
std::tie(this->stage, this->features.mesh, this->feature_toggles.mesh) <=>
|
||||
std::tie(other.stage, other.features.mesh, other.feature_toggles.mesh)
|
||||
);
|
||||
case geometries::point_cloud:
|
||||
return (
|
||||
std::tie(this->stage, this->features.point_cloud, this->feature_toggles.point_cloud) <=>
|
||||
std::tie(other.stage, other.features.point_cloud, other.feature_toggles.point_cloud)
|
||||
);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->geometry <=> other.geometry;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const metadata_type& other) const noexcept
|
||||
{
|
||||
if (this->geometry == other.geometry)
|
||||
{
|
||||
switch (this->geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
return (
|
||||
std::tie(this->stage, this->features.mesh, this->feature_toggles.mesh) ==
|
||||
std::tie(other.stage, other.features.mesh, other.feature_toggles.mesh)
|
||||
);
|
||||
case geometries::point_cloud:
|
||||
return (
|
||||
std::tie(this->stage, this->features.point_cloud, this->feature_toggles.point_cloud) ==
|
||||
std::tie(other.stage, other.features.point_cloud, other.feature_toggles.point_cloud)
|
||||
);
|
||||
}
|
||||
std::unreachable();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
struct feature_ignorant_less
|
||||
{
|
||||
bool operator()(const metadata_type& a, const metadata_type& b) const
|
||||
{
|
||||
return (
|
||||
std::tie(a.geometry, a.stage) <
|
||||
std::tie(a.geometry, b.stage)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
struct feature_count_less
|
||||
{
|
||||
bool operator()(const metadata_type& a, const metadata_type& b) const
|
||||
{
|
||||
if (a.geometry == b.geometry)
|
||||
{
|
||||
int feature_count{}, feature_toggle_count{};
|
||||
int other_feature_count{}, other_feature_toggle_count{};
|
||||
|
||||
constexpr auto count_features = []<typename T>(const T features)
|
||||
{
|
||||
using int_type = std::underlying_type_t<T>;
|
||||
using uint_type = std::make_unsigned_t<int_type>;
|
||||
return std::popcount(static_cast<uint_type>(static_cast<int_type>(features)));
|
||||
};
|
||||
|
||||
switch (a.geometry)
|
||||
{
|
||||
case geometries::mesh:
|
||||
for (auto& [ count, features ] : {
|
||||
std::tie(feature_count, a.features.mesh),
|
||||
std::tie(feature_toggle_count, a.feature_toggles.mesh),
|
||||
std::tie(other_feature_count, b.features.mesh),
|
||||
std::tie(other_feature_toggle_count, b.feature_toggles.mesh)
|
||||
}) {
|
||||
count = count_features(features);
|
||||
}
|
||||
case geometries::point_cloud:
|
||||
for (auto& [ count, features ] : {
|
||||
std::tie(feature_count, a.features.point_cloud),
|
||||
std::tie(feature_toggle_count, a.feature_toggles.point_cloud),
|
||||
std::tie(other_feature_count, b.features.point_cloud),
|
||||
std::tie(other_feature_toggle_count, b.feature_toggles.point_cloud)
|
||||
}) {
|
||||
count = count_features(features);
|
||||
}
|
||||
default:
|
||||
std::unreachable();
|
||||
}
|
||||
return (
|
||||
std::tie(a.stage, feature_count, feature_toggle_count) <
|
||||
std::tie(b.stage, other_feature_count, other_feature_toggle_count)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return a.geometry < b.geometry;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUM_TYPE) \
|
||||
#define DEFINE_ENUM_BITFIELD_OPERATORS(ENUM_TYPE) \
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator|( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
@@ -35,6 +35,24 @@
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE operator<<( \
|
||||
ENUM_TYPE& lhs, \
|
||||
int shift \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) << shift \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE operator<<( \
|
||||
ENUM_TYPE& lhs, \
|
||||
int shift \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) << shift \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator|=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
@@ -54,4 +72,18 @@ constexpr ENUM_TYPE& operator^=( \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs ^ rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator<<=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const int shift \
|
||||
) { \
|
||||
return lhs = lhs << shift; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator>>=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const int shift \
|
||||
) { \
|
||||
return lhs = lhs >> shift; \
|
||||
}
|
||||
Reference in New Issue
Block a user