tried making naming more uniform and implemented most of the opengl managers
This commit is contained in:
99
source/assets/data/material_data.ipp
Normal file
99
source/assets/data/material_data.ipp
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION
|
||||
# error Never include this file directly include 'dynamic_material_buffer.hpp'
|
||||
#endif
|
||||
|
||||
|
||||
inline std::optional<assets::material_components::surface_properties>& assets::material_data::surface_properties()
|
||||
{
|
||||
return std::get<material_components::indices::surface_properties>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::transparency>& assets::material_data::transparency()
|
||||
{
|
||||
return std::get<material_components::indices::transparency>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::ambient_color_texture>& assets::material_data::ambient_color_texture_id()
|
||||
{
|
||||
return std::get<material_components::indices::ambient_color_texture>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::diffuse_color_texture>& assets::material_data::diffuse_color_texture_id()
|
||||
{
|
||||
return std::get<material_components::indices::diffuse_color_texture>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::specular_color_texture>& assets::material_data::specular_color_texture_id()
|
||||
{
|
||||
return std::get<material_components::indices::specular_color_texture>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::shininess_texture>& assets::material_data::shininess_texture_id()
|
||||
{
|
||||
return std::get<material_components::indices::shininess_texture>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::alpha_texture>& assets::material_data::alpha_texture_id()
|
||||
{
|
||||
return std::get<material_components::indices::alpha_texture>(data);
|
||||
}
|
||||
inline std::optional<assets::material_components::bump_texture>& assets::material_data::bump_texture_id()
|
||||
{
|
||||
return std::get<material_components::indices::bump_texture(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::surface_properties>& assets::material_data::surface_properties() const
|
||||
{
|
||||
return std::get<material_components::indices::surface_properties>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::transparency>& assets::material_data::transparency() const
|
||||
{
|
||||
return std::get<material_components::indices::transparency>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::ambient_color_texture>& assets::material_data::ambient_color_texture_id() const
|
||||
{
|
||||
return std::get<material_components::indices::ambient_color_texture>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::diffuse_color_texture>& assets::material_data::diffuse_color_texture_id() const
|
||||
{
|
||||
return std::get<material_components::indices::diffuse_color_texture>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::specular_color_texture>& assets::material_data::specular_color_texture_id() const
|
||||
{
|
||||
return std::get<material_components::indices::specular_color_texture>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::shininess_texture>& assets::material_data::shininess_texture_id() const
|
||||
{
|
||||
return std::get<material_components::indices::shininess_texture>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::alpha_texture>& assets::material_data::alpha_texture_id() const
|
||||
{
|
||||
return std::get<material_components::indices::alpha_texture>(data);
|
||||
}
|
||||
|
||||
inline const std::optional<assets::material_components::bump_texture>& assets::material_data::bump_texture_id() const
|
||||
{
|
||||
return std::get<material_components::indices::bump_texture>(data);
|
||||
}
|
||||
|
||||
|
||||
inline assets::material_components::surface_properties& assets::material_data::initialized_surface_properties()
|
||||
{
|
||||
auto& surface_properties_opt = surface_properties();
|
||||
if (not surface_properties_opt)
|
||||
{
|
||||
surface_properties_opt = material_components::surface_properties{};
|
||||
}
|
||||
return *surface_properties_opt;
|
||||
}
|
||||
|
||||
inline void assets::material_data::clear()
|
||||
{
|
||||
std::apply(
|
||||
[](auto&... data_opt) {
|
||||
(data_opt.reset(), ...);
|
||||
},
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
80
source/assets/data/mesh_data.ipp
Normal file
80
source/assets/data/mesh_data.ipp
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION
|
||||
# error Never include this file directly include 'dynamic_mesh_buffer.hpp'
|
||||
#endif
|
||||
|
||||
inline std::vector<assets::mesh_vertex_components::position>& assets::mesh_data::positions()
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::position>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::mesh_vertex_components::normal>& assets::mesh_data::normals()
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::normal>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::mesh_vertex_components::tex_coord>& assets::mesh_data::tex_coords()
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::tex_coord>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::mesh_vertex_components::color>& assets::mesh_data::colors()
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::color>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::mesh_vertex_components::reflectance>& assets::mesh_data::reflectances()
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::reflectance>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::mesh_data::triangle_type>& assets::mesh_data::triangles()
|
||||
{
|
||||
return m_triangles;
|
||||
}
|
||||
|
||||
inline auto& assets::mesh_data::material_id()
|
||||
{
|
||||
return m_material_id;
|
||||
}
|
||||
|
||||
inline const std::vector<assets::mesh_vertex_components::position>& assets::mesh_data::positions() const
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::position>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::mesh_vertex_components::normal>& assets::mesh_data::normals() const
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::normal>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::mesh_vertex_components::tex_coord>& assets::mesh_data::tex_coords() const
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::tex_coord>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::mesh_vertex_components::color>& assets::mesh_data::colors() const
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::color>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::mesh_vertex_components::reflectance>& assets::mesh_data::reflectances() const
|
||||
{
|
||||
return std::get<mesh_vertex_components::indices::reflectance>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::mesh_data::triangle_type>& assets::mesh_data::triangles() const
|
||||
{
|
||||
return m_triangles;
|
||||
}
|
||||
|
||||
inline const auto& assets::mesh_data::material_id() const
|
||||
{
|
||||
return m_material_id;
|
||||
}
|
||||
|
||||
inline void assets::mesh_data::clear()
|
||||
{
|
||||
clear_vertices();
|
||||
m_triangles.clear();
|
||||
m_material_id = {};
|
||||
}
|
||||
49
source/assets/data/point_cloud_data.ipp
Normal file
49
source/assets/data/point_cloud_data.ipp
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
# error Never include this file directly include 'dynamic_point_cloud_buffer.hpp'
|
||||
#endif
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
inline std::vector<assets::point_cloud_vertex_components::position>& assets::point_cloud_data::positions()
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::position>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::point_cloud_vertex_components::normal>& assets::point_cloud_data::normals()
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::normal>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::point_cloud_vertex_components::color>& assets::point_cloud_data::colors()
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::color>(vertices);
|
||||
}
|
||||
|
||||
inline std::vector<assets::point_cloud_vertex_components::reflectance>& assets::point_cloud_data::reflectances()
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::reflectance>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::point_cloud_vertex_components::position>& assets::point_cloud_data::positions() const
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::position>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::point_cloud_vertex_components::normal>& assets::point_cloud_data::normals() const
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::normal>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::point_cloud_vertex_components::color>& assets::point_cloud_data::colors() const
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::color>(vertices);
|
||||
}
|
||||
|
||||
inline const std::vector<assets::point_cloud_vertex_components::reflectance>& assets::point_cloud_data::reflectances() const
|
||||
{
|
||||
return std::get<point_cloud_vertex_components::indices::reflectance>(vertices);
|
||||
}
|
||||
|
||||
inline void assets::point_cloud_data::clear()
|
||||
{
|
||||
clear_vertices();
|
||||
}
|
||||
159
source/assets/data/texture_data.ipp
Normal file
159
source/assets/data/texture_data.ipp
Normal file
@@ -0,0 +1,159 @@
|
||||
#ifndef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
# error Never include this file directly include 'dynamic_texture_buffer.hpp'
|
||||
#endif
|
||||
|
||||
|
||||
inline assets::texture_data::texture_data(
|
||||
std::unique_ptr<value_type[]>&& data,
|
||||
const dim_type width,
|
||||
const dim_type height,
|
||||
const texture_components::flags components
|
||||
) :
|
||||
m_data{ std::move(data) },
|
||||
m_width{ width },
|
||||
m_height{ height },
|
||||
m_components{ components }
|
||||
{};
|
||||
|
||||
inline assets::texture_data::texture_data(const assets::texture_data& other) :
|
||||
m_data{ new value_type[other.component_count()] },
|
||||
m_width{ other.m_width },
|
||||
m_height{ other.m_height },
|
||||
m_components{ other.m_components }
|
||||
{
|
||||
std::copy_n(other.m_data.get(), other.m_width * other.m_height, this->m_data.get());
|
||||
}
|
||||
|
||||
inline assets::texture_data::texture_data(texture_data&& other) noexcept :
|
||||
m_data{ std::move(other.m_data) },
|
||||
m_width{ other.m_width },
|
||||
m_height{ other.m_height },
|
||||
m_components{ other.m_components }
|
||||
{
|
||||
other.m_width = 0;
|
||||
other.m_height = 0;
|
||||
other.m_components = texture_components::flags::none;
|
||||
}
|
||||
|
||||
inline assets::texture_data& assets::texture_data::operator=(const assets::texture_data& other)
|
||||
{
|
||||
if (this != &other) [[likely]]
|
||||
{
|
||||
|
||||
const auto m_size = this->component_count();
|
||||
const auto o_size = other.component_count();
|
||||
|
||||
if (o_size > m_size) {
|
||||
this->~texture_data();
|
||||
this->m_data.reset(new value_type[o_size]);
|
||||
}
|
||||
|
||||
std::copy_n(other.m_data.get(), o_size, this->m_data.get());
|
||||
|
||||
this->m_width = other.m_width;
|
||||
this->m_height = other.m_height;
|
||||
this->m_components = other.m_components;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline assets::texture_data& assets::texture_data::operator=(texture_data&& other) noexcept
|
||||
{
|
||||
if (this != &other) [[likely]]
|
||||
{
|
||||
this->~texture_data();
|
||||
|
||||
this->m_data = std::move(other.m_data);
|
||||
this->m_width = other.m_width;
|
||||
this->m_height = other.m_height;
|
||||
|
||||
other.m_width = 0;
|
||||
other.m_height = 0;
|
||||
other.m_components = texture_components::flags::none;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline assets::texture_components::flags assets::texture_data::components() const
|
||||
{
|
||||
return m_components;
|
||||
}
|
||||
|
||||
inline assets::texture_data::dim_type assets::texture_data::width() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
inline assets::texture_data::dim_type assets::texture_data::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
inline std::pair<assets::texture_data::dim_type, assets::texture_data::dim_type> assets::texture_data::dimensions() const
|
||||
{
|
||||
return { m_width, m_height };
|
||||
}
|
||||
|
||||
inline assets::texture_data::size_type assets::texture_data::pixel_count() const
|
||||
{
|
||||
return static_cast<size_type>(m_width) * static_cast<size_type>(m_height);
|
||||
}
|
||||
|
||||
inline assets::texture_data::size_type assets::texture_data::component_count() const
|
||||
{
|
||||
return std::popcount(static_cast<std::underlying_type_t<texture_components::flags>>(m_components));
|
||||
}
|
||||
|
||||
inline assets::texture_data::size_type assets::texture_data::size() const
|
||||
{
|
||||
return pixel_count() * component_count();
|
||||
}
|
||||
|
||||
inline assets::texture_data::const_pointer assets::texture_data::data() const
|
||||
{
|
||||
return m_data.get();
|
||||
}
|
||||
|
||||
inline assets::texture_data::pointer assets::texture_data::data()
|
||||
{
|
||||
return m_data.get();
|
||||
}
|
||||
|
||||
inline assets::texture_data::const_iterator assets::texture_data::begin() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
|
||||
inline assets::texture_data::iterator assets::texture_data::begin()
|
||||
{
|
||||
return data();
|
||||
}
|
||||
|
||||
inline assets::texture_data::const_iterator assets::texture_data::end() const
|
||||
{
|
||||
return begin() + component_count();
|
||||
}
|
||||
|
||||
inline assets::texture_data::iterator assets::texture_data::end()
|
||||
{
|
||||
return begin() + component_count();
|
||||
}
|
||||
|
||||
inline assets::texture_data::const_iterator assets::texture_data::cbegin() const
|
||||
{
|
||||
return const_cast<const_iterator>(begin());
|
||||
}
|
||||
|
||||
inline assets::texture_data::const_iterator assets::texture_data::cend() const
|
||||
{
|
||||
return const_cast<const_iterator>(begin());
|
||||
}
|
||||
|
||||
inline void assets::texture_data::clear()
|
||||
{
|
||||
m_data.reset();
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_components = {};
|
||||
}
|
||||
Reference in New Issue
Block a user