// Copyright (C) 2015 Jérôme Leclercq // 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_VERTEXDECLARATION_HPP #define NAZARA_VERTEXDECLARATION_HPP #include #include #include #include #include #include #include namespace Nz { class VertexDeclaration; using VertexDeclarationConstRef = ObjectRef; using VertexDeclarationLibrary = ObjectLibrary; using VertexDeclarationRef = ObjectRef; class NAZARA_UTILITY_API VertexDeclaration : public RefCounted { friend VertexDeclarationLibrary; friend class Utility; public: VertexDeclaration(); VertexDeclaration(const VertexDeclaration& declaration); ~VertexDeclaration(); void DisableComponent(VertexComponent component); void EnableComponent(VertexComponent component, ComponentType type, std::size_t offset); void GetComponent(VertexComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const; std::size_t GetStride() const; void SetStride(std::size_t stride); VertexDeclaration& operator=(const VertexDeclaration& declaration); static VertexDeclaration* Get(VertexLayout layout); static bool IsTypeSupported(ComponentType type); template static VertexDeclarationRef New(Args&&... args); // Signals: NazaraSignal(OnVertexDeclarationRelease, const VertexDeclaration* /*vertexDeclaration*/); private: static bool Initialize(); static void Uninitialize(); struct Component { ComponentType type; // Le type de donnée bool enabled = false; // Ce composant est-il activé ?/ std::size_t offset; // La position, en octets, de la première donnée /* ** -Lynix: ** Il serait aussi possible de préciser le stride de façon indépendante, ce que je ne permets pas ** pour décomplexifier l'interface en enlevant quelque chose que je juge inutile. ** Si vous pensez que ça peut être utile, n'hésitez pas à me le faire savoir ! ** PS: Même cas pour le diviseur (instancing) */ }; Component m_components[VertexComponent_Max+1]; std::size_t m_stride; static VertexDeclaration s_declarations[VertexLayout_Max+1]; static VertexDeclarationLibrary::LibraryMap s_library; }; } #include #endif // NAZARA_VERTEXDECLARATION_HPP