// Copyright (C) 2021 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_UTILITY_VERTEXDECLARATION_HPP #define NAZARA_UTILITY_VERTEXDECLARATION_HPP #include #include #include #include #include #include #include namespace Nz { class VertexDeclaration; using VertexDeclarationLibrary = ObjectLibrary; class NAZARA_UTILITY_API VertexDeclaration { friend VertexDeclarationLibrary; friend class Utility; public: struct Component; struct ComponentEntry; VertexDeclaration(VertexInputRate inputRate, std::initializer_list components); VertexDeclaration(const VertexDeclaration&) = delete; VertexDeclaration(VertexDeclaration&&) = delete; ~VertexDeclaration() = default; inline const Component* FindComponent(VertexComponent vertexComponent, std::size_t componentIndex) const; template const Component* GetComponentByType(VertexComponent vertexComponent, std::size_t componentIndex = 0) const; inline const Component& GetComponent(std::size_t componentIndex) const; inline std::size_t GetComponentCount() const; inline const std::vector& GetComponents() const; inline VertexInputRate GetInputRate() const; inline std::size_t GetStride() const; inline bool HasComponent(VertexComponent component, std::size_t componentIndex = 0) const; template bool HasComponentOfType(VertexComponent vertexComponent, std::size_t componentIndex = 0) const; VertexDeclaration& operator=(const VertexDeclaration&) = delete; VertexDeclaration& operator=(VertexDeclaration&&) = delete; static inline const std::shared_ptr& Get(VertexLayout layout); static bool IsTypeSupported(ComponentType type); struct Component { ComponentType type; VertexComponent component; std::size_t componentIndex; std::size_t offset; }; struct ComponentEntry { VertexComponent component; ComponentType type; std::size_t componentIndex; }; private: static bool Initialize(); static void Uninitialize(); std::vector m_components; std::size_t m_stride; VertexInputRate m_inputRate; static std::array, VertexLayoutCount> s_declarations; }; } #include #endif // NAZARA_UTILITY_VERTEXDECLARATION_HPP