tried making naming more uniform and implemented most of the opengl managers

This commit is contained in:
ZY4N
2025-03-25 02:22:44 +01:00
parent c609d49f0d
commit 71ea2d9237
155 changed files with 4097 additions and 2434 deletions

View File

@@ -0,0 +1,21 @@
#pragma once
#include <vector>
template<typename C, typename... Ts>
struct vertex_array_data
{
C component_flags;
std::tuple<std::vector<Ts>...> vertices{};
protected:
void clear_vertices()
{
std::apply(
[](auto&... vertex_opt) {
(vertex_opt.clear(), ...);
},
vertices
);
}
};

View File

@@ -0,0 +1,56 @@
#pragma once
#include <optional>
#include "assets/components/material_components.hpp"
#include "assets/data_stores/texture_store.hpp"
namespace assets
{
struct material_data
{
material_data() = default;
material_components::surface_properties& initialized_surface_properties();
[[nodiscard]] inline std::optional<material_components::surface_properties>& surface_properties();
[[nodiscard]] inline std::optional<material_components::transparency>& transparency();
[[nodiscard]] inline std::optional<material_components::ambient_color_texture>& ambient_color_texture_id();
[[nodiscard]] inline std::optional<material_components::diffuse_color_texture>& diffuse_color_texture_id();
[[nodiscard]] inline std::optional<material_components::specular_color_texture>& specular_color_texture_id();
[[nodiscard]] inline std::optional<material_components::shininess_texture>& shininess_texture_id();
[[nodiscard]] inline std::optional<material_components::alpha_texture>& alpha_texture_id();
[[nodiscard]] inline std::optional<material_components::bump_texture>& bump_texture_id();
[[nodiscard]] inline const std::optional<material_components::surface_properties>& surface_properties() const;
[[nodiscard]] inline const std::optional<material_components::transparency>& transparency() const;
[[nodiscard]] inline const std::optional<material_components::ambient_color_texture>& ambient_color_texture_id() const;
[[nodiscard]] inline const std::optional<material_components::diffuse_color_texture>& diffuse_color_texture_id() const;
[[nodiscard]] inline const std::optional<material_components::specular_color_texture>& specular_color_texture_id() const;
[[nodiscard]] inline const std::optional<material_components::shininess_texture>& shininess_texture_id() const;
[[nodiscard]] inline const std::optional<material_components::alpha_texture>& alpha_texture_id() const;
[[nodiscard]] inline const std::optional<material_components::bump_texture>& bump_texture_id() const;
inline void clear();
std::tuple<
std::optional<material_components::surface_properties>,
std::optional<material_components::transparency>,
std::optional<material_components::ambient_color_texture>,
std::optional<material_components::diffuse_color_texture>,
std::optional<material_components::specular_color_texture>,
std::optional<material_components::shininess_texture>,
std::optional<material_components::alpha_texture>,
std::optional<material_components::bump_texture>
> data{
std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt
};
};
}
#define INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION
#include "assets/data/material_data.ipp"
#undef INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION

View File

@@ -0,0 +1,11 @@
#pragma once
#include "util/string_lookup.hpp"
#include "assets/data_stores/material_store.hpp"
namespace assets
{
using material_library_data = ztu::string_lookup<material_store::id_type>;
}

View File

@@ -0,0 +1,53 @@
#pragma once
#include <array>
#include <vector>
#include "util/uix.hpp"
#include "assets/components/mesh_vertex_components.hpp"
#include "generic/vertex_array_data.hpp"
#include "assets/data_stores/material_store.hpp"
namespace assets
{
class mesh_data : public vertex_array_data<
mesh_vertex_components::flags,
mesh_vertex_components::position,
mesh_vertex_components::normal,
mesh_vertex_components::tex_coord,
mesh_vertex_components::color,
mesh_vertex_components::reflectance
> {
public:
using index_type = ztu::u32;
using triangle_type = std::array<index_type, 3>;
[[nodiscard]] inline std::vector<mesh_vertex_components::position>& positions();
[[nodiscard]] inline std::vector<mesh_vertex_components::normal>& normals();
[[nodiscard]] inline std::vector<mesh_vertex_components::tex_coord>& tex_coords();
[[nodiscard]] inline std::vector<mesh_vertex_components::color>& colors();
[[nodiscard]] inline std::vector<mesh_vertex_components::reflectance>& reflectances();
[[nodiscard]] inline std::vector<triangle_type>& triangles();
[[nodiscard]] inline auto& material_id();
[[nodiscard]] inline const std::vector<mesh_vertex_components::position>& positions() const;
[[nodiscard]] inline const std::vector<mesh_vertex_components::normal>& normals() const;
[[nodiscard]] inline const std::vector<mesh_vertex_components::tex_coord>& tex_coords() const;
[[nodiscard]] inline const std::vector<mesh_vertex_components::color>& colors() const;
[[nodiscard]] inline const std::vector<mesh_vertex_components::reflectance>& reflectances() const;
[[nodiscard]] inline const std::vector<triangle_type>& triangles() const;
[[nodiscard]] inline const auto& material_id() const;
inline void clear();
private:
std::vector<triangle_type> m_triangles{};
material_store::id_type m_material_id{};
};
}
#define INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION
#include "assets/data/mesh_data.ipp"
#undef INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION

View File

@@ -0,0 +1,37 @@
#pragma once
#include "assets/components/point_cloud_vertex_components.hpp"
#include <array>
#include <vector>
#include "generic/vertex_array_data.hpp"
namespace assets
{
class point_cloud_data : public vertex_array_data<
point_cloud_vertex_components::flags,
point_cloud_vertex_components::position,
point_cloud_vertex_components::normal,
point_cloud_vertex_components::color,
point_cloud_vertex_components::reflectance
> {
public:
[[nodiscard]] inline std::vector<point_cloud_vertex_components::position>& positions();
[[nodiscard]] inline std::vector<point_cloud_vertex_components::normal>& normals();
[[nodiscard]] inline std::vector<point_cloud_vertex_components::color>& colors();
[[nodiscard]] inline std::vector<point_cloud_vertex_components::reflectance>& reflectances();
[[nodiscard]] inline const std::vector<point_cloud_vertex_components::position>& positions() const;
[[nodiscard]] inline const std::vector<point_cloud_vertex_components::normal>& normals() const;
[[nodiscard]] inline const std::vector<point_cloud_vertex_components::color>& colors() const;
[[nodiscard]] inline const std::vector<point_cloud_vertex_components::reflectance>& reflectances() const;
inline void clear();
};
}
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
#include "assets/data/point_cloud_data.ipp"
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION

View File

@@ -0,0 +1,10 @@
#pragma once
#include "glm/mat4x4.hpp"
namespace assets
{
using pose_data = glm::mat4;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <vector>
namespace assets
{
struct shader_source_data
{
std::vector<char> source{};
void clear()
{
source.clear();
}
};
}

View File

@@ -2,10 +2,15 @@
#include <array>
namespace assets
{
struct surface_properties
{
std::array<float, 3> ambient_filter{ 0.7f, 0.7f, 0.7f };
std::array<float, 3> diffuse_filter{ 0.466f, 0.466f, 0.7922f };
std::array<float, 3> specular_filter{ 0.5974f, 0.2084f, 0.2084f };
float shininess{ 100.2237f };
};
};
}

View File

@@ -0,0 +1,85 @@
#pragma once
#include <cinttypes>
#include <bit>
#include <memory>
#include <algorithm>
#include "assets/components/texture_components.hpp"
namespace assets
{
class texture_data
{
public:
using value_type = std::uint8_t;
using dim_type = std::int32_t;
using size_type = std::make_signed_t<std::size_t>;
using difference_type = size_type;
using reference = value_type&;
using const_reference = const value_type&;
using pointer = std::uint8_t*;
using const_pointer = const std::uint8_t*;
using iterator = pointer;
using const_iterator = const_pointer;
texture_data() = default;
inline texture_data(
std::unique_ptr<value_type[]>&& data,
dim_type width,
dim_type height,
texture_components::flags components
);;
inline texture_data(const texture_data&);
inline texture_data(texture_data&&) noexcept;
[[nodiscard]] inline texture_data& operator=(const texture_data&);
[[nodiscard]] inline texture_data& operator=(texture_data&&) noexcept;
[[nodiscard]] inline texture_components::flags components() const;
[[nodiscard]] inline dim_type width() const;
[[nodiscard]] inline dim_type height() const;
[[nodiscard]] inline std::pair<dim_type, dim_type> dimensions() const;
[[nodiscard]] inline size_type pixel_count() const;
[[nodiscard]] inline size_type component_count() const;
[[nodiscard]] inline size_type size() const;
[[nodiscard]] inline const_iterator begin() const;
[[nodiscard]] inline iterator begin();
[[nodiscard]] inline const_iterator end() const;
[[nodiscard]] inline iterator end();
[[nodiscard]] inline const_iterator cbegin() const;
[[nodiscard]] inline const_iterator cend() const;
[[nodiscard]] inline const_pointer data() const;
[[nodiscard]] inline pointer data();
void inline clear();
private:
std::unique_ptr<value_type[]> m_data{ nullptr };
dim_type m_width{ 0 }, m_height{ 0 };
texture_components::flags m_components{ texture_components::flags::none };
};
}
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
#include "assets/data/texture_data.ipp"
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION