This commit is contained in:
ZY4N
2024-12-22 16:58:40 +01:00
parent 2704814de2
commit db8db8f9d7
161 changed files with 17102 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
#pragma once
#include "opengl/handles/mesh_handle.hpp"
#include "util/uix.hpp"
#include <system_error>
#include <span>
#include "assets/components/mesh_vertex_components.hpp"
#include "GL/glew.h"
namespace zgl
{
struct mesh_data
{
private:
mesh_data(
GLuint vertex_vbo_id,
GLuint index_vbo_id,
GLuint vao_id,
ztu::u32 material_id,
components::mesh_vertex::flags components,
GLsizei index_count
);
public:
mesh_data() = default;
[[nodiscard]] static std::error_code build_from(
std::span<const std::uint8_t> vertex_buffer,
std::span<const GLenum> component_types,
std::span<const GLint> component_lengths,
GLsizei stride,
std::span<const ztu::u32> index_buffer,
ztu::u32 material_id,
components::mesh_vertex::flags components,
mesh_data& data
);
mesh_data(const mesh_data& other) = delete;
mesh_data& operator=(const mesh_data& other) = delete;
mesh_data(mesh_data&& other) noexcept;
mesh_data& operator=(mesh_data&& other) noexcept;
~mesh_data();
[[nodiscard]] mesh_handle handle() const;
[[nodiscard]] components::mesh_vertex::flags components() const;
[[nodiscard]] ztu::u32 material_id() const;
private:
mesh_handle m_handle{};
GLuint m_vertex_vbo_id{ 0 };
GLuint m_index_vbo_id{ 0 };
ztu::u32 m_material_id{ 0 };
components::mesh_vertex::flags m_component_types{
components::mesh_vertex::flags::none
};
};
}
#define INCLUDE_MESH_DATA_IMPLEMENTATION
#include "opengl/data/mesh_data.ipp"
#undef INCLUDE_MESH_DATA_IMPLEMENTATION