Files
NazaraEngine/include/Nazara/Utility/VertexDeclaration.hpp
Lynix 8f9ea9db17 Added ResourceListenerWrapper
This class wraps the call to
Resource::AddResourceListener/RemoveResourceListener using RAII and help
a lot with some of the dependencies.
Thanks to this, the render queues now handle their resources listening
properly.

Former-commit-id: 7f215ffa4ccadcc4f44f777656970e92ce01087a
2015-01-18 23:59:01 +01:00

71 lines
2.3 KiB
C++

// Copyright (C) 2014 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 <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceListenerWrapper.hpp>
#include <Nazara/Core/ResourceRef.hpp>
#include <Nazara/Utility/Enums.hpp>
class NzVertexDeclaration;
using NzVertexDeclarationConstListener = NzResourceListenerWrapper<const NzVertexDeclaration>;
using NzVertexDeclarationConstRef = NzResourceRef<const NzVertexDeclaration>;
using NzVertexDeclarationListener = NzResourceListenerWrapper<NzVertexDeclaration>;
using NzVertexDeclarationRef = NzResourceRef<NzVertexDeclaration>;
class NAZARA_API NzVertexDeclaration : public NzResource
{
friend class NzUtility;
public:
NzVertexDeclaration();
NzVertexDeclaration(const NzVertexDeclaration& declaration);
~NzVertexDeclaration();
void DisableComponent(nzVertexComponent component);
void EnableComponent(nzVertexComponent component, nzComponentType type, unsigned int offset);
void GetComponent(nzVertexComponent component, bool* enabled, nzComponentType* type, unsigned int* offset) const;
unsigned int GetStride() const;
void SetStride(unsigned int stride);
NzVertexDeclaration& operator=(const NzVertexDeclaration& declaration);
static NzVertexDeclaration* Get(nzVertexLayout layout);
static bool IsTypeSupported(nzComponentType type);
private:
static bool Initialize();
static void Uninitialize();
struct Component
{
nzComponentType type; // Le type de donnée
bool enabled = false; // Ce composant est-il activé ?/
unsigned int 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[nzVertexComponent_Max+1];
unsigned int m_stride;
static NzVertexDeclaration s_declarations[nzVertexLayout_Max+1];
};
#endif // NAZARA_VERTEXDECLARATION_HPP