Reworked IndexBuffer, Vertex[Buffer|Declaration|Structs]
Former-commit-id: e3f637f2680afda57a444f73b8f7ad681bb1b8a5
This commit is contained in:
@@ -12,15 +12,6 @@
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
struct NzVertexElement
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int usageIndex = 0;
|
||||
nzElementStream stream = nzElementStream_VertexData;
|
||||
nzElementType type;
|
||||
nzElementUsage usage;
|
||||
};
|
||||
|
||||
class NzVertexDeclaration;
|
||||
|
||||
using NzVertexDeclarationConstRef = NzResourceRef<const NzVertexDeclaration>;
|
||||
@@ -30,38 +21,45 @@ struct NzVertexDeclarationImpl;
|
||||
|
||||
class NAZARA_API NzVertexDeclaration : public NzResource
|
||||
{
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
NzVertexDeclaration() = default;
|
||||
NzVertexDeclaration(const NzVertexElement* elements, unsigned int elementCount);
|
||||
NzVertexDeclaration(const NzVertexDeclaration& declaration);
|
||||
NzVertexDeclaration(NzVertexDeclaration&& declaration) noexcept;
|
||||
~NzVertexDeclaration();
|
||||
NzVertexDeclaration();
|
||||
NzVertexDeclaration(NzVertexDeclaration& declaration);
|
||||
~NzVertexDeclaration() = default;
|
||||
|
||||
bool Create(const NzVertexElement* elements, unsigned int elementCount);
|
||||
void Destroy();
|
||||
void DisableAttribute(nzAttributeUsage usage);
|
||||
void EnableAttribute(nzAttributeUsage usage, nzAttributeType type, unsigned int offset);
|
||||
|
||||
const NzVertexElement* GetElement(unsigned int i) const;
|
||||
const NzVertexElement* GetElement(nzElementStream stream, unsigned int i) const;
|
||||
const NzVertexElement* GetElement(nzElementStream stream, nzElementUsage usage, unsigned int usageIndex = 0) const;
|
||||
unsigned int GetElementCount() const;
|
||||
unsigned int GetElementCount(nzElementStream stream) const;
|
||||
unsigned int GetStride(nzElementStream stream) const;
|
||||
void GetAttribute(nzAttributeUsage usage, bool* enabled, nzAttributeType* type, unsigned int* offset) const;
|
||||
unsigned int GetStride() const;
|
||||
|
||||
bool HasElement(unsigned int i) const;
|
||||
bool HasElement(nzElementStream stream, unsigned int i) const;
|
||||
bool HasElement(nzElementStream stream, nzElementUsage usage, unsigned int usageIndex = 0) const;
|
||||
bool HasStream(nzElementStream stream) const;
|
||||
|
||||
bool IsValid() const;
|
||||
void SetStride(unsigned int stride);
|
||||
|
||||
NzVertexDeclaration& operator=(const NzVertexDeclaration& declaration);
|
||||
NzVertexDeclaration& operator=(NzVertexDeclaration&& declaration) noexcept;
|
||||
|
||||
static unsigned int GetElementCount(nzElementType type);
|
||||
static unsigned int GetElementSize(nzElementType type);
|
||||
static NzVertexDeclaration* Get(nzVertexLayout layout);
|
||||
static unsigned int GetAttributeSize(nzAttributeType type);
|
||||
|
||||
private:
|
||||
NzVertexDeclarationImpl* m_sharedImpl = nullptr;
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
struct Attribute
|
||||
{
|
||||
nzAttributeType type;
|
||||
bool enabled = false;
|
||||
unsigned int offset;
|
||||
// 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 d'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)
|
||||
};
|
||||
|
||||
Attribute m_attributes[nzAttributeUsage_Max+1];
|
||||
unsigned int m_stride;
|
||||
|
||||
static NzVertexDeclaration s_declarations[nzVertexLayout_Max+1];
|
||||
};
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
|
||||
Reference in New Issue
Block a user