Switch from Nz prefix to namespace Nz

What a huge commit


Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
Lynix
2015-09-25 19:20:05 +02:00
parent c214251ecf
commit df8da275c4
609 changed files with 68265 additions and 66534 deletions

View File

@@ -15,26 +15,29 @@
#include <Nazara/Utility/Enums.hpp>
#include <unordered_map>
class NzAbstractImage;
class NzImage;
class NAZARA_UTILITY_API NzAbstractAtlas
namespace Nz
{
public:
NzAbstractAtlas() = default;
virtual ~NzAbstractAtlas();
class AbstractImage;
class Image;
virtual void Clear() = 0;
virtual void Free(NzSparsePtr<const NzRectui> rects, NzSparsePtr<unsigned int> layers, unsigned int count) = 0;
virtual NzAbstractImage* GetLayer(unsigned int layerIndex) const = 0;
virtual unsigned int GetLayerCount() const = 0;
virtual nzUInt32 GetStorage() const = 0;
virtual bool Insert(const NzImage& image, NzRectui* rect, bool* flipped, unsigned int* layerIndex) = 0;
class NAZARA_UTILITY_API AbstractAtlas
{
public:
AbstractAtlas() = default;
virtual ~AbstractAtlas();
// Signals:
NazaraSignal(OnAtlasCleared, const NzAbstractAtlas* /*atlas*/);
NazaraSignal(OnAtlasLayerChange, const NzAbstractAtlas* /*atlas*/, NzAbstractImage* /*oldLayer*/, NzAbstractImage* /*newLayer*/);
NazaraSignal(OnAtlasRelease, const NzAbstractAtlas* /*atlas*/);
};
virtual void Clear() = 0;
virtual void Free(SparsePtr<const Rectui> rects, SparsePtr<unsigned int> layers, unsigned int count) = 0;
virtual AbstractImage* GetLayer(unsigned int layerIndex) const = 0;
virtual unsigned int GetLayerCount() const = 0;
virtual UInt32 GetStorage() const = 0;
virtual bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex) = 0;
// Signals:
NazaraSignal(OnAtlasCleared, const AbstractAtlas* /*atlas*/);
NazaraSignal(OnAtlasLayerChange, const AbstractAtlas* /*atlas*/, AbstractImage* /*oldLayer*/, AbstractImage* /*newLayer*/);
NazaraSignal(OnAtlasRelease, const AbstractAtlas* /*atlas*/);
};
}
#endif // NAZARA_ABSTRACTATLAS_HPP

View File

@@ -9,21 +9,24 @@
#include <Nazara/Utility/Buffer.hpp>
class NAZARA_UTILITY_API NzAbstractBuffer
namespace Nz
{
public:
NzAbstractBuffer() = default;
virtual ~NzAbstractBuffer();
class NAZARA_UTILITY_API AbstractBuffer
{
public:
AbstractBuffer() = default;
virtual ~AbstractBuffer();
virtual bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static) = 0;
virtual void Destroy() = 0;
virtual bool Create(unsigned int size, BufferUsage usage = BufferUsage_Static) = 0;
virtual void Destroy() = 0;
virtual bool Fill(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false) = 0;
virtual bool Fill(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false) = 0;
virtual bool IsHardware() const = 0;
virtual bool IsHardware() const = 0;
virtual void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0) = 0;
virtual bool Unmap() = 0;
};
virtual void* Map(BufferAccess access, unsigned int offset = 0, unsigned int size = 0) = 0;
virtual bool Unmap() = 0;
};
}
#endif // NAZARA_ABSTRACTBUFFER_HPP

View File

@@ -14,30 +14,33 @@
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
class NAZARA_UTILITY_API NzAbstractImage
namespace Nz
{
public:
NzAbstractImage() = default;
virtual ~NzAbstractImage();
class NAZARA_UTILITY_API AbstractImage
{
public:
AbstractImage() = default;
virtual ~AbstractImage();
nzUInt8 GetBytesPerPixel() const;
virtual unsigned int GetDepth(nzUInt8 level = 0) const = 0;
virtual nzPixelFormat GetFormat() const = 0;
virtual unsigned int GetHeight(nzUInt8 level = 0) const = 0;
virtual nzUInt8 GetLevelCount() const = 0;
virtual nzUInt8 GetMaxLevel() const = 0;
virtual unsigned int GetMemoryUsage() const = 0;
virtual unsigned int GetMemoryUsage(nzUInt8 level) const = 0;
virtual NzVector3ui GetSize(nzUInt8 level = 0) const = 0;
virtual nzImageType GetType() const = 0;
virtual unsigned int GetWidth(nzUInt8 level = 0) const = 0;
UInt8 GetBytesPerPixel() const;
virtual unsigned int GetDepth(UInt8 level = 0) const = 0;
virtual PixelFormatType GetFormat() const = 0;
virtual unsigned int GetHeight(UInt8 level = 0) const = 0;
virtual UInt8 GetLevelCount() const = 0;
virtual UInt8 GetMaxLevel() const = 0;
virtual unsigned int GetMemoryUsage() const = 0;
virtual unsigned int GetMemoryUsage(UInt8 level) const = 0;
virtual Vector3ui GetSize(UInt8 level = 0) const = 0;
virtual ImageType GetType() const = 0;
virtual unsigned int GetWidth(UInt8 level = 0) const = 0;
bool IsCompressed() const;
bool IsCubemap() const;
bool IsCompressed() const;
bool IsCubemap() const;
virtual bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0) = 0;
virtual bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0) = 0;
virtual bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0) = 0;
};
virtual bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) = 0;
virtual bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) = 0;
virtual bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) = 0;
};
}
#endif // NAZARA_IMAGE_HPP

View File

@@ -13,31 +13,34 @@
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Utility/Config.hpp>
class NzAbstractImage;
class NzFont;
class NAZARA_UTILITY_API NzAbstractTextDrawer
namespace Nz
{
public:
struct Glyph;
class AbstractImage;
class Font;
NzAbstractTextDrawer() = default;
virtual ~NzAbstractTextDrawer();
class NAZARA_UTILITY_API AbstractTextDrawer
{
public:
struct Glyph;
virtual const NzRectui& GetBounds() const = 0;
virtual NzFont* GetFont(unsigned int index) const = 0;
virtual unsigned int GetFontCount() const = 0;
virtual const Glyph& GetGlyph(unsigned int index) const = 0;
virtual unsigned int GetGlyphCount() const = 0;
AbstractTextDrawer() = default;
virtual ~AbstractTextDrawer();
struct Glyph
{
NzColor color;
NzRectui atlasRect;
NzVector2f corners[4];
NzAbstractImage* atlas;
bool flipped;
};
};
virtual const Rectui& GetBounds() const = 0;
virtual Font* GetFont(unsigned int index) const = 0;
virtual unsigned int GetFontCount() const = 0;
virtual const Glyph& GetGlyph(unsigned int index) const = 0;
virtual unsigned int GetGlyphCount() const = 0;
struct Glyph
{
Color color;
Rectui atlasRect;
Vector2f corners[4];
AbstractImage* atlas;
bool flipped;
};
};
}
#endif // NAZARA_ABSTRACTTEXTDRAWER_HPP

View File

@@ -17,43 +17,46 @@
#include <Nazara/Utility/Mesh.hpp>
#include <Nazara/Utility/SkeletalMesh.hpp>
struct NzSkinningData
namespace Nz
{
const NzJoint* joints;
const NzSkeletalMeshVertex* inputVertex;
NzMeshVertex* outputVertex;
};
struct SkinningData
{
const Joint* joints;
const SkeletalMeshVertex* inputVertex;
MeshVertex* outputVertex;
};
struct NzVertexPointers
{
NzSparsePtr<NzVector3f> normalPtr;
NzSparsePtr<NzVector3f> positionPtr;
NzSparsePtr<NzVector3f> tangentPtr;
NzSparsePtr<NzVector2f> uvPtr;
};
struct VertexPointers
{
SparsePtr<Vector3f> normalPtr;
SparsePtr<Vector3f> positionPtr;
SparsePtr<Vector3f> tangentPtr;
SparsePtr<Vector2f> uvPtr;
};
NAZARA_UTILITY_API NzBoxf NzComputeAABB(NzSparsePtr<const NzVector3f> positionPtr, unsigned int vertexCount);
NAZARA_UTILITY_API void NzComputeBoxIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API unsigned int NzComputeCacheMissCount(NzIndexIterator indices, unsigned int indexCount);
NAZARA_UTILITY_API void NzComputeConeIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void NzComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void NzComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void NzComputePlaneIndexVertexCount(const NzVector2ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void NzComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr<const Vector3f> positionPtr, unsigned int vertexCount);
NAZARA_UTILITY_API void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API unsigned int ComputeCacheMissCount(IndexIterator indices, unsigned int indexCount);
NAZARA_UTILITY_API void ComputeConeIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount);
NAZARA_UTILITY_API void NzGenerateBox(const NzVector3f& lengths, const NzVector3ui& subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzVertexPointers vertexPointers, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void NzGenerateCone(float length, float radius, unsigned int subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzVertexPointers vertexPointers, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzVertexPointers vertexPointers, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void NzGenerateIcoSphere(float size, unsigned int recursionLevel, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzVertexPointers vertexPointers, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector2f& size, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzVertexPointers vertexPointers, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzVertexPointers vertexPointers, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void GenerateIcoSphere(float size, unsigned int recursionLevel, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void GeneratePlane(const Vector2ui& subdivision, const Vector2f& size, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void GenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0);
NAZARA_UTILITY_API void NzOptimizeIndices(NzIndexIterator indices, unsigned int indexCount);
NAZARA_UTILITY_API void OptimizeIndices(IndexIterator indices, unsigned int indexCount);
NAZARA_UTILITY_API void NzSkinPosition(const NzSkinningData& data, unsigned int startVertex, unsigned int vertexCount);
NAZARA_UTILITY_API void NzSkinPositionNormal(const NzSkinningData& data, unsigned int startVertex, unsigned int vertexCount);
NAZARA_UTILITY_API void NzSkinPositionNormalTangent(const NzSkinningData& data, unsigned int startVertex, unsigned int vertexCount);
NAZARA_UTILITY_API void SkinPosition(const SkinningData& data, unsigned int startVertex, unsigned int vertexCount);
NAZARA_UTILITY_API void SkinPositionNormal(const SkinningData& data, unsigned int startVertex, unsigned int vertexCount);
NAZARA_UTILITY_API void SkinPositionNormalTangent(const SkinningData& data, unsigned int startVertex, unsigned int vertexCount);
NAZARA_UTILITY_API void NzTransformVertices(NzVertexPointers vertexPointers, unsigned int vertexCount, const NzMatrix4f& matrix);
NAZARA_UTILITY_API void TransformVertices(VertexPointers vertexPointers, unsigned int vertexCount, const Matrix4f& matrix);
}
#endif // NAZARA_ALGORITHM_UTILITY_HPP

View File

@@ -21,88 +21,91 @@
#include <Nazara/Utility/Sequence.hpp>
#include <limits>
struct NAZARA_UTILITY_API NzAnimationParams
namespace Nz
{
// La frame de fin à charger
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
// La frame de début à charger
unsigned int startFrame = 0;
struct NAZARA_UTILITY_API AnimationParams
{
// La frame de fin à charger
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
// La frame de début à charger
unsigned int startFrame = 0;
bool IsValid() const;
};
class NzAnimation;
class NzSkeleton;
using NzAnimationConstRef = NzObjectRef<const NzAnimation>;
using NzAnimationLibrary = NzObjectLibrary<NzAnimation>;
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
using NzAnimationManager = NzResourceManager<NzAnimation, NzAnimationParams>;
using NzAnimationRef = NzObjectRef<NzAnimation>;
struct NzAnimationImpl;
class NAZARA_UTILITY_API NzAnimation : public NzRefCounted, public NzResource
{
friend NzAnimationLibrary;
friend NzAnimationLoader;
friend NzAnimationManager;
friend class NzUtility;
public:
NzAnimation() = default;
~NzAnimation();
bool AddSequence(const NzSequence& sequence);
void AnimateSkeleton(NzSkeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const;
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
void Destroy();
void EnableLoopPointInterpolation(bool loopPointInterpolation);
unsigned int GetFrameCount() const;
unsigned int GetJointCount() const;
NzSequence* GetSequence(const NzString& sequenceName);
NzSequence* GetSequence(unsigned int index);
const NzSequence* GetSequence(const NzString& sequenceName) const;
const NzSequence* GetSequence(unsigned int index) const;
unsigned int GetSequenceCount() const;
int GetSequenceIndex(const NzString& sequenceName) const;
NzSequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0);
const NzSequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const;
nzAnimationType GetType() const;
bool HasSequence(const NzString& sequenceName) const;
bool HasSequence(unsigned int index = 0) const;
bool IsLoopPointInterpolationEnabled() const;
bool IsValid() const;
};
bool LoadFromFile(const NzString& filePath, const NzAnimationParams& params = NzAnimationParams());
bool LoadFromMemory(const void* data, std::size_t size, const NzAnimationParams& params = NzAnimationParams());
bool LoadFromStream(NzInputStream& stream, const NzAnimationParams& params = NzAnimationParams());
class Animation;
class Skeleton;
void RemoveSequence(const NzString& sequenceName);
void RemoveSequence(unsigned int index);
using AnimationConstRef = ObjectRef<const Animation>;
using AnimationLibrary = ObjectLibrary<Animation>;
using AnimationLoader = ResourceLoader<Animation, AnimationParams>;
using AnimationManager = ResourceManager<Animation, AnimationParams>;
using AnimationRef = ObjectRef<Animation>;
template<typename... Args> static NzAnimationRef New(Args&&... args);
struct AnimationImpl;
// Signals:
NazaraSignal(OnAnimationDestroy, const NzAnimation* /*animation*/);
NazaraSignal(OnAnimationRelease, const NzAnimation* /*animation*/);
class NAZARA_UTILITY_API Animation : public RefCounted, public Resource
{
friend AnimationLibrary;
friend AnimationLoader;
friend AnimationManager;
friend class Utility;
private:
static bool Initialize();
static void Uninitialize();
public:
Animation() = default;
~Animation();
NzAnimationImpl* m_impl = nullptr;
bool AddSequence(const Sequence& sequence);
void AnimateSkeleton(Skeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const;
static NzAnimationLibrary::LibraryMap s_library;
static NzAnimationLoader::LoaderList s_loaders;
static NzAnimationManager::ManagerMap s_managerMap;
static NzAnimationManager::ManagerParams s_managerParameters;
};
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
void Destroy();
void EnableLoopPointInterpolation(bool loopPointInterpolation);
unsigned int GetFrameCount() const;
unsigned int GetJointCount() const;
Sequence* GetSequence(const String& sequenceName);
Sequence* GetSequence(unsigned int index);
const Sequence* GetSequence(const String& sequenceName) const;
const Sequence* GetSequence(unsigned int index) const;
unsigned int GetSequenceCount() const;
int GetSequenceIndex(const String& sequenceName) const;
SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0);
const SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const;
AnimationType GetType() const;
bool HasSequence(const String& sequenceName) const;
bool HasSequence(unsigned int index = 0) const;
bool IsLoopPointInterpolationEnabled() const;
bool IsValid() const;
bool LoadFromFile(const String& filePath, const AnimationParams& params = AnimationParams());
bool LoadFromMemory(const void* data, std::size_t size, const AnimationParams& params = AnimationParams());
bool LoadFromStream(InputStream& stream, const AnimationParams& params = AnimationParams());
void RemoveSequence(const String& sequenceName);
void RemoveSequence(unsigned int index);
template<typename... Args> static AnimationRef New(Args&&... args);
// Signals:
NazaraSignal(OnAnimationDestroy, const Animation* /*animation*/);
NazaraSignal(OnAnimationRelease, const Animation* /*animation*/);
private:
static bool Initialize();
static void Uninitialize();
AnimationImpl* m_impl = nullptr;
static AnimationLibrary::LibraryMap s_library;
static AnimationLoader::LoaderList s_loaders;
static AnimationManager::ManagerMap s_managerMap;
static AnimationManager::ManagerParams s_managerParameters;
};
}
#include <Nazara/Utility/Animation.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzAnimationRef NzAnimation::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzAnimation> object(new NzAnimation(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
AnimationRef Animation::New(Args&&... args)
{
std::unique_ptr<Animation> object(new Animation(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -14,72 +14,75 @@
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
class NzBuffer;
using NzBufferConstRef = NzObjectRef<const NzBuffer>;
using NzBufferRef = NzObjectRef<NzBuffer>;
class NzAbstractBuffer;
class NAZARA_UTILITY_API NzBuffer : public NzRefCounted
namespace Nz
{
friend class NzUtility;
class Buffer;
public:
using BufferFactory = NzAbstractBuffer* (*)(NzBuffer* parent, nzBufferType type);
using BufferConstRef = ObjectRef<const Buffer>;
using BufferRef = ObjectRef<Buffer>;
NzBuffer(nzBufferType type);
NzBuffer(nzBufferType type, unsigned int size, nzUInt32 storage = nzDataStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzBuffer(const NzBuffer&) = delete;
NzBuffer(NzBuffer&&) = delete;
~NzBuffer();
class AbstractBuffer;
bool CopyContent(const NzBuffer& buffer);
class NAZARA_UTILITY_API Buffer : public RefCounted
{
friend class Utility;
bool Create(unsigned int size, nzUInt32 storage = nzDataStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
void Destroy();
public:
using BufferFactory = AbstractBuffer* (*)(Buffer* parent, BufferType type);
bool Fill(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);
Buffer(BufferType type);
Buffer(BufferType type, unsigned int size, UInt32 storage = DataStorage_Software, BufferUsage usage = BufferUsage_Static);
Buffer(const Buffer&) = delete;
Buffer(Buffer&&) = delete;
~Buffer();
NzAbstractBuffer* GetImpl() const;
unsigned int GetSize() const;
nzUInt32 GetStorage() const;
nzBufferType GetType() const;
nzBufferUsage GetUsage() const;
bool CopyContent(const Buffer& buffer);
bool IsHardware() const;
bool IsValid() const;
bool Create(unsigned int size, UInt32 storage = DataStorage_Software, BufferUsage usage = BufferUsage_Static);
void Destroy();
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0);
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0) const;
bool Fill(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);
bool SetStorage(nzUInt32 storage);
AbstractBuffer* GetImpl() const;
unsigned int GetSize() const;
UInt32 GetStorage() const;
BufferType GetType() const;
BufferUsage GetUsage() const;
void Unmap() const;
bool IsHardware() const;
bool IsValid() const;
NzBuffer& operator=(const NzBuffer&) = delete;
NzBuffer& operator=(NzBuffer&&) = delete;
void* Map(BufferAccess access, unsigned int offset = 0, unsigned int size = 0);
void* Map(BufferAccess access, unsigned int offset = 0, unsigned int size = 0) const;
static bool IsStorageSupported(nzUInt32 storage);
template<typename... Args> static NzBufferRef New(Args&&... args);
static void SetBufferFactory(nzUInt32 storage, BufferFactory func);
bool SetStorage(UInt32 storage);
// Signals:
NazaraSignal(OnBufferDestroy, const NzBuffer* /*buffer*/);
NazaraSignal(OnBufferRelease, const NzBuffer* /*buffer*/);
void Unmap() const;
private:
static bool Initialize();
static void Uninitialize();
Buffer& operator=(const Buffer&) = delete;
Buffer& operator=(Buffer&&) = delete;
nzBufferType m_type;
nzBufferUsage m_usage;
nzUInt32 m_storage;
NzAbstractBuffer* m_impl;
unsigned int m_size;
static bool IsStorageSupported(UInt32 storage);
template<typename... Args> static BufferRef New(Args&&... args);
static void SetBufferFactory(UInt32 storage, BufferFactory func);
static BufferFactory s_bufferFactories[nzDataStorage_Max+1];
};
// Signals:
NazaraSignal(OnBufferDestroy, const Buffer* /*buffer*/);
NazaraSignal(OnBufferRelease, const Buffer* /*buffer*/);
private:
static bool Initialize();
static void Uninitialize();
BufferType m_type;
BufferUsage m_usage;
UInt32 m_storage;
AbstractBuffer* m_impl;
unsigned int m_size;
static BufferFactory s_bufferFactories[DataStorage_Max+1];
};
}
#include <Nazara/Utility/Buffer.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzBufferRef NzBuffer::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzBuffer> object(new NzBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
BufferRef Buffer::New(Args&&... args)
{
std::unique_ptr<Buffer> object(new Buffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -9,31 +9,34 @@
#include <Nazara/Utility/Enums.hpp>
template<class T>
class NzBufferMapper
namespace Nz
{
public:
NzBufferMapper();
NzBufferMapper(T* buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
NzBufferMapper(T& buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
NzBufferMapper(const T* buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
NzBufferMapper(const T& buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
~NzBufferMapper();
template<class T>
class BufferMapper
{
public:
BufferMapper();
BufferMapper(T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
BufferMapper(T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
BufferMapper(const T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
BufferMapper(const T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
~BufferMapper();
bool Map(T* buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(T& buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(const T* buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(const T& buffer, nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(const T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
bool Map(const T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
const T* GetBuffer() const;
void* GetPointer() const;
const T* GetBuffer() const;
void* GetPointer() const;
void Unmap();
void Unmap();
private:
const T* m_buffer;
void* m_ptr;
};
private:
const T* m_buffer;
void* m_ptr;
};
}
#include <Nazara/Utility/BufferMapper.inl>

View File

@@ -7,125 +7,128 @@
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Debug.hpp>
template<typename T>
NzBufferMapper<T>::NzBufferMapper() :
m_buffer(nullptr),
m_ptr(nullptr)
namespace Nz
{
}
template<typename T>
NzBufferMapper<T>::NzBufferMapper(T* buffer, nzBufferAccess access, unsigned int offset, unsigned int length) :
m_buffer(nullptr)
{
if (!Map(buffer, access, offset, length))
NazaraError("Failed to map buffer"); ///TODO: Unexpected
}
template<typename T>
NzBufferMapper<T>::NzBufferMapper(T& buffer, nzBufferAccess access, unsigned int offset, unsigned int length) :
NzBufferMapper(&buffer, access, offset, length)
{
}
template<typename T>
NzBufferMapper<T>::NzBufferMapper(const T* buffer, nzBufferAccess access, unsigned int offset, unsigned int length) :
m_buffer(nullptr)
{
if (!Map(buffer, access, offset, length))
NazaraError("Failed to map buffer"); ///TODO: Unexpected
}
template<typename T>
NzBufferMapper<T>::NzBufferMapper(const T& buffer, nzBufferAccess access, unsigned int offset, unsigned int length) :
NzBufferMapper(&buffer, access, offset, length)
{
}
template<typename T>
NzBufferMapper<T>::~NzBufferMapper()
{
if (m_buffer)
m_buffer->Unmap();
}
template<typename T>
const T* NzBufferMapper<T>::GetBuffer() const
{
return m_buffer;
}
template<typename T>
void* NzBufferMapper<T>::GetPointer() const
{
return m_ptr;
}
template<typename T>
bool NzBufferMapper<T>::Map(T* buffer, nzBufferAccess access, unsigned int offset, unsigned int length)
{
Unmap();
#if NAZARA_UTILITY_SAFE
if (!buffer)
template<typename T>
BufferMapper<T>::BufferMapper() :
m_buffer(nullptr),
m_ptr(nullptr)
{
NazaraError("Buffer must be valid");
m_ptr = nullptr;
return false;
}
#endif
m_buffer = buffer;
m_ptr = buffer->Map(access, offset, length);
if (!m_ptr)
NazaraError("Failed to map buffer"); ///TODO: Unexpected
return true;
}
template<typename T>
bool NzBufferMapper<T>::Map(T& buffer, nzBufferAccess access, unsigned int offset, unsigned int length)
{
return Map(&buffer, access, offset, length);
}
template<typename T>
bool NzBufferMapper<T>::Map(const T* buffer, nzBufferAccess access, unsigned int offset, unsigned int length)
{
Unmap();
#if NAZARA_UTILITY_SAFE
if (!buffer)
template<typename T>
BufferMapper<T>::BufferMapper(T* buffer, BufferAccess access, unsigned int offset, unsigned int length) :
m_buffer(nullptr)
{
NazaraError("Buffer must be valid");
m_ptr = nullptr;
return false;
if (!Map(buffer, access, offset, length))
NazaraError("Failed to map buffer"); ///TODO: Unexpected
}
#endif
m_buffer = buffer;
m_ptr = buffer->Map(access, offset, length);
if (!m_ptr)
NazaraError("Failed to map buffer"); ///TODO: Unexpected
return true;
}
template<typename T>
bool NzBufferMapper<T>::Map(const T& buffer, nzBufferAccess access, unsigned int offset, unsigned int length)
{
return Map(&buffer, access, offset, length);
}
template<typename T>
void NzBufferMapper<T>::Unmap()
{
if (m_buffer)
template<typename T>
BufferMapper<T>::BufferMapper(T& buffer, BufferAccess access, unsigned int offset, unsigned int length) :
BufferMapper(&buffer, access, offset, length)
{
m_buffer->Unmap();
m_buffer = nullptr;
}
template<typename T>
BufferMapper<T>::BufferMapper(const T* buffer, BufferAccess access, unsigned int offset, unsigned int length) :
m_buffer(nullptr)
{
if (!Map(buffer, access, offset, length))
NazaraError("Failed to map buffer"); ///TODO: Unexpected
}
template<typename T>
BufferMapper<T>::BufferMapper(const T& buffer, BufferAccess access, unsigned int offset, unsigned int length) :
BufferMapper(&buffer, access, offset, length)
{
}
template<typename T>
BufferMapper<T>::~BufferMapper()
{
if (m_buffer)
m_buffer->Unmap();
}
template<typename T>
const T* BufferMapper<T>::GetBuffer() const
{
return m_buffer;
}
template<typename T>
void* BufferMapper<T>::GetPointer() const
{
return m_ptr;
}
template<typename T>
bool BufferMapper<T>::Map(T* buffer, BufferAccess access, unsigned int offset, unsigned int length)
{
Unmap();
#if NAZARA_UTILITY_SAFE
if (!buffer)
{
NazaraError("Buffer must be valid");
m_ptr = nullptr;
return false;
}
#endif
m_buffer = buffer;
m_ptr = buffer->Map(access, offset, length);
if (!m_ptr)
NazaraError("Failed to map buffer"); ///TODO: Unexpected
return true;
}
template<typename T>
bool BufferMapper<T>::Map(T& buffer, BufferAccess access, unsigned int offset, unsigned int length)
{
return Map(&buffer, access, offset, length);
}
template<typename T>
bool BufferMapper<T>::Map(const T* buffer, BufferAccess access, unsigned int offset, unsigned int length)
{
Unmap();
#if NAZARA_UTILITY_SAFE
if (!buffer)
{
NazaraError("Buffer must be valid");
m_ptr = nullptr;
return false;
}
#endif
m_buffer = buffer;
m_ptr = buffer->Map(access, offset, length);
if (!m_ptr)
NazaraError("Failed to map buffer"); ///TODO: Unexpected
return true;
}
template<typename T>
bool BufferMapper<T>::Map(const T& buffer, BufferAccess access, unsigned int offset, unsigned int length)
{
return Map(&buffer, access, offset, length);
}
template<typename T>
void BufferMapper<T>::Unmap()
{
if (m_buffer)
{
m_buffer->Unmap();
m_buffer = nullptr;
}
}
}

View File

@@ -9,27 +9,30 @@
#include <Nazara/Math/Vector2.hpp>
struct NzCubemapParams
namespace Nz
{
/*
La position de chaque face dans la cubemap
Les indices ici seront multipliés à la taille d'une face pour obtenir le coin haut-gauche de la zone.
Si la taille d'une face est 0, elle sera calculée via max(width, height)/4.
struct CubemapParams
{
/*
La position de chaque face dans la cubemap
Les indices ici seront multipliés à la taille d'une face pour obtenir le coin haut-gauche de la zone.
Si la taille d'une face est 0, elle sera calculée via max(width, height)/4.
Par défaut, cela suit ce layout :
U
L F R B
D
Par défaut, cela suit ce layout :
U
L F R B
D
Si ce n'est pas le cas, à vous de repositionner les faces correctement.
*/
NzVector2ui backPosition = NzVector2ui(3, 1);
NzVector2ui downPosition = NzVector2ui(1, 2);
NzVector2ui forwardPosition = NzVector2ui(1, 1);
NzVector2ui leftPosition = NzVector2ui(0, 1);
NzVector2ui rightPosition = NzVector2ui(2, 1);
NzVector2ui upPosition = NzVector2ui(1, 0);
unsigned int faceSize = 0;
};
Si ce n'est pas le cas, à vous de repositionner les faces correctement.
*/
Vector2ui backPosition = Vector2ui(3, 1);
Vector2ui downPosition = Vector2ui(1, 2);
Vector2ui forwardPosition = Vector2ui(1, 1);
Vector2ui leftPosition = Vector2ui(0, 1);
Vector2ui rightPosition = Vector2ui(2, 1);
Vector2ui upPosition = Vector2ui(1, 0);
unsigned int faceSize = 0;
};
}
#endif // NAZARA_CUBEMAPPARAMS_HPP

View File

@@ -11,25 +11,28 @@
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Utility/Config.hpp>
class NzCursorImpl;
class NzImage;
class NAZARA_UTILITY_API NzCursor
namespace Nz
{
friend class NzWindowImpl;
class CursorImpl;
class Image;
public:
NzCursor();
~NzCursor();
class NAZARA_UTILITY_API Cursor
{
friend class WindowImpl;
bool Create(const NzImage& cursor, int hotSpotX = 0, int hotSpotY = 0);
bool Create(const NzImage& cursor, const NzVector2i& hotSpot);
void Destroy();
public:
Cursor();
~Cursor();
bool IsValid() const;
bool Create(const Image& cursor, int hotSpotX = 0, int hotSpotY = 0);
bool Create(const Image& cursor, const Vector2i& hotSpot);
void Destroy();
private:
NzCursorImpl* m_impl;
};
bool IsValid() const;
private:
CursorImpl* m_impl;
};
}
#endif // NAZARA_CURSOR_HPP

View File

@@ -7,326 +7,329 @@
#ifndef NAZARA_ENUMS_UTILITY_HPP
#define NAZARA_ENUMS_UTILITY_HPP
enum nzAnimationType
namespace Nz
{
nzAnimationType_Skeletal,
nzAnimationType_Static,
enum AnimationType
{
AnimationType_Skeletal,
AnimationType_Static,
nzAnimationType_Max = nzAnimationType_Static
};
AnimationType_Max = AnimationType_Static
};
enum nzBufferAccess
{
nzBufferAccess_DiscardAndWrite,
nzBufferAccess_ReadOnly,
nzBufferAccess_ReadWrite,
nzBufferAccess_WriteOnly,
enum BufferAccess
{
BufferAccess_DiscardAndWrite,
BufferAccess_ReadOnly,
BufferAccess_ReadWrite,
BufferAccess_WriteOnly,
nzBufferAccess_Max = nzBufferAccess_WriteOnly
};
BufferAccess_Max = BufferAccess_WriteOnly
};
enum nzBufferType
{
nzBufferType_Index,
nzBufferType_Vertex,
enum BufferType
{
BufferType_Index,
BufferType_Vertex,
nzBufferType_Max = nzBufferType_Vertex
};
BufferType_Max = BufferType_Vertex
};
enum nzBufferUsage
{
nzBufferUsage_Dynamic,
nzBufferUsage_Static,
enum BufferUsage
{
BufferUsage_Dynamic,
BufferUsage_Static,
nzBufferUsage_Max = nzBufferUsage_Static
};
BufferUsage_Max = BufferUsage_Static
};
enum nzComponentType
{
nzComponentType_Color,
nzComponentType_Double1,
nzComponentType_Double2,
nzComponentType_Double3,
nzComponentType_Double4,
nzComponentType_Float1,
nzComponentType_Float2,
nzComponentType_Float3,
nzComponentType_Float4,
nzComponentType_Int1,
nzComponentType_Int2,
nzComponentType_Int3,
nzComponentType_Int4,
nzComponentType_Quaternion,
enum ComponentType
{
ComponentType_Color,
ComponentType_Double1,
ComponentType_Double2,
ComponentType_Double3,
ComponentType_Double4,
ComponentType_Float1,
ComponentType_Float2,
ComponentType_Float3,
ComponentType_Float4,
ComponentType_Int1,
ComponentType_Int2,
ComponentType_Int3,
ComponentType_Int4,
ComponentType_Quaternion,
nzComponentType_Max = nzComponentType_Quaternion
};
ComponentType_Max = ComponentType_Quaternion
};
enum nzCubemapFace
{
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap
// L'ordre est X, -X, Y, -Y, Z, -Z
nzCubemapFace_PositiveX = 0,
nzCubemapFace_PositiveY = 2,
nzCubemapFace_PositiveZ = 4,
nzCubemapFace_NegativeX = 1,
nzCubemapFace_NegativeY = 3,
nzCubemapFace_NegativeZ = 5,
enum CubemapFace
{
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de Image contenant un cubemap
// L'ordre est X, -X, Y, -Y, Z, -Z
CubemapFace_PositiveX = 0,
CubemapFace_PositiveY = 2,
CubemapFace_PositiveZ = 4,
CubemapFace_NegativeX = 1,
CubemapFace_NegativeY = 3,
CubemapFace_NegativeZ = 5,
nzCubemapFace_Max = nzCubemapFace_NegativeZ
};
CubemapFace_Max = CubemapFace_NegativeZ
};
enum nzDataStorageFlags
{
nzDataStorage_Hardware = 0x1,
nzDataStorage_Software = 0x2,
enum DataStorageFlags
{
DataStorage_Hardware = 0x1,
DataStorage_Software = 0x2,
nzDataStorage_Both = nzDataStorage_Hardware | nzDataStorage_Software,
DataStorage_Both = DataStorage_Hardware | DataStorage_Software,
nzDataStorage_Max = nzDataStorage_Software*2-1
};
DataStorage_Max = DataStorage_Software*2-1
};
enum nzEventType
{
nzEventType_GainedFocus,
nzEventType_LostFocus,
nzEventType_KeyPressed,
nzEventType_KeyReleased,
nzEventType_MouseButtonDoubleClicked,
nzEventType_MouseButtonPressed,
nzEventType_MouseButtonReleased,
nzEventType_MouseEntered,
nzEventType_MouseLeft,
nzEventType_MouseMoved,
nzEventType_MouseWheelMoved,
nzEventType_Moved,
nzEventType_Quit,
nzEventType_Resized,
nzEventType_TextEntered,
enum ImageType
{
ImageType_1D,
ImageType_1D_Array,
ImageType_2D,
ImageType_2D_Array,
ImageType_3D,
ImageType_Cubemap,
nzEventType_Max = nzEventType_TextEntered
};
ImageType_Max = ImageType_Cubemap
};
enum nzImageType
{
nzImageType_1D,
nzImageType_1D_Array,
nzImageType_2D,
nzImageType_2D_Array,
nzImageType_3D,
nzImageType_Cubemap,
enum nzNodeType
{
nzNodeType_Default, // Node
nzNodeType_Scene, // SceneNode (Graphics)
nzNodeType_Skeletal, ///TODO
nzImageType_Max = nzImageType_Cubemap
};
nzNodeType_Max = nzNodeType_Skeletal
};
enum nzNodeType
{
nzNodeType_Default, // NzNode
nzNodeType_Scene, // NzSceneNode (Graphics)
nzNodeType_Skeletal, ///TODO
enum PixelFormatType
{
PixelFormatType_Undefined = -1,
nzNodeType_Max = nzNodeType_Skeletal
};
PixelFormatType_A8, // 1*uint8
PixelFormatType_BGR8, // 3*uint8
PixelFormatType_BGRA8, // 4*uint8
PixelFormatType_DXT1,
PixelFormatType_DXT3,
PixelFormatType_DXT5,
PixelFormatType_L8, // 1*uint8
PixelFormatType_LA8, // 2*uint8
PixelFormatType_R8, // 1*uint8
PixelFormatType_R8I, // 1*int8
PixelFormatType_R8UI, // 1*uint8
PixelFormatType_R16, // 1*uint16
PixelFormatType_R16F, // 1*half
PixelFormatType_R16I, // 1*int16
PixelFormatType_R16UI, // 1*uint16
PixelFormatType_R32F, // 1*float
PixelFormatType_R32I, // 1*uint16
PixelFormatType_R32UI, // 1*uint32
PixelFormatType_RG8, // 2*int8
PixelFormatType_RG8I, // 2*int8
PixelFormatType_RG8UI, // 2*uint8
PixelFormatType_RG16, // 2*uint16
PixelFormatType_RG16F, // 2*half
PixelFormatType_RG16I, // 2*int16
PixelFormatType_RG16UI, // 2*uint16
PixelFormatType_RG32F, // 2*float
PixelFormatType_RG32I, // 2*uint16
PixelFormatType_RG32UI, // 2*uint32
PixelFormatType_RGB5A1, // 3*uint5 + alpha bit
PixelFormatType_RGB8, // 3*uint8
PixelFormatType_RGB16F, // 3*half
PixelFormatType_RGB16I, // 4*int16
PixelFormatType_RGB16UI, // 4*uint16
PixelFormatType_RGB32F, // 3*float
PixelFormatType_RGB32I, // 4*int32
PixelFormatType_RGB32UI, // 4*uint32
PixelFormatType_RGBA4, // 4*uint4
PixelFormatType_RGBA8, // 4*uint8
PixelFormatType_RGBA16F, // 4*half
PixelFormatType_RGBA16I, // 4*int16
PixelFormatType_RGBA16UI, // 4*uint16
PixelFormatType_RGBA32F, // 4*float
PixelFormatType_RGBA32I, // 4*int32
PixelFormatType_RGBA32UI, // 4*uint32
PixelFormatType_Depth16,
PixelFormatType_Depth24,
PixelFormatType_Depth24Stencil8,
PixelFormatType_Depth32,
PixelFormatType_Stencil1,
PixelFormatType_Stencil4,
PixelFormatType_Stencil8,
PixelFormatType_Stencil16,
enum nzPixelFormat
{
nzPixelFormat_Undefined = -1,
PixelFormatType_Max = PixelFormatType_Stencil16
};
nzPixelFormat_A8, // 1*uint8
nzPixelFormat_BGR8, // 3*uint8
nzPixelFormat_BGRA8, // 4*uint8
nzPixelFormat_DXT1,
nzPixelFormat_DXT3,
nzPixelFormat_DXT5,
nzPixelFormat_L8, // 1*uint8
nzPixelFormat_LA8, // 2*uint8
nzPixelFormat_R8, // 1*uint8
nzPixelFormat_R8I, // 1*int8
nzPixelFormat_R8UI, // 1*uint8
nzPixelFormat_R16, // 1*uint16
nzPixelFormat_R16F, // 1*half
nzPixelFormat_R16I, // 1*int16
nzPixelFormat_R16UI, // 1*uint16
nzPixelFormat_R32F, // 1*float
nzPixelFormat_R32I, // 1*uint16
nzPixelFormat_R32UI, // 1*uint32
nzPixelFormat_RG8, // 2*int8
nzPixelFormat_RG8I, // 2*int8
nzPixelFormat_RG8UI, // 2*uint8
nzPixelFormat_RG16, // 2*uint16
nzPixelFormat_RG16F, // 2*half
nzPixelFormat_RG16I, // 2*int16
nzPixelFormat_RG16UI, // 2*uint16
nzPixelFormat_RG32F, // 2*float
nzPixelFormat_RG32I, // 2*uint16
nzPixelFormat_RG32UI, // 2*uint32
nzPixelFormat_RGB5A1, // 3*uint5 + alpha bit
nzPixelFormat_RGB8, // 3*uint8
nzPixelFormat_RGB16F, // 3*half
nzPixelFormat_RGB16I, // 4*int16
nzPixelFormat_RGB16UI, // 4*uint16
nzPixelFormat_RGB32F, // 3*float
nzPixelFormat_RGB32I, // 4*int32
nzPixelFormat_RGB32UI, // 4*uint32
nzPixelFormat_RGBA4, // 4*uint4
nzPixelFormat_RGBA8, // 4*uint8
nzPixelFormat_RGBA16F, // 4*half
nzPixelFormat_RGBA16I, // 4*int16
nzPixelFormat_RGBA16UI, // 4*uint16
nzPixelFormat_RGBA32F, // 4*float
nzPixelFormat_RGBA32I, // 4*int32
nzPixelFormat_RGBA32UI, // 4*uint32
nzPixelFormat_Depth16,
nzPixelFormat_Depth24,
nzPixelFormat_Depth24Stencil8,
nzPixelFormat_Depth32,
nzPixelFormat_Stencil1,
nzPixelFormat_Stencil4,
nzPixelFormat_Stencil8,
nzPixelFormat_Stencil16,
enum PixelFormatTypeType
{
PixelFormatTypeType_Undefined = -1,
nzPixelFormat_Max = nzPixelFormat_Stencil16
};
PixelFormatTypeType_Color,
PixelFormatTypeType_Depth,
PixelFormatTypeType_DepthStencil,
PixelFormatTypeType_Stencil,
enum nzPixelFormatType
{
nzPixelFormatType_Undefined = -1,
PixelFormatTypeType_Max = PixelFormatTypeType_Stencil
};
nzPixelFormatType_Color,
nzPixelFormatType_Depth,
nzPixelFormatType_DepthStencil,
nzPixelFormatType_Stencil,
enum PixelFlipping
{
PixelFlipping_Horizontally,
PixelFlipping_Vertically,
nzPixelFormatType_Max = nzPixelFormatType_Stencil
};
PixelFlipping_Max = PixelFlipping_Vertically
};
enum nzPixelFlipping
{
nzPixelFlipping_Horizontally,
nzPixelFlipping_Vertically,
enum PrimitiveMode
{
PrimitiveMode_LineList,
PrimitiveMode_LineStrip,
PrimitiveMode_PointList,
PrimitiveMode_TriangleList,
PrimitiveMode_TriangleStrip,
PrimitiveMode_TriangleFan,
nzPixelFlipping_Max = nzPixelFlipping_Vertically
};
PrimitiveMode_Max = PrimitiveMode_TriangleFan
};
enum nzPrimitiveMode
{
nzPrimitiveMode_LineList,
nzPrimitiveMode_LineStrip,
nzPrimitiveMode_PointList,
nzPrimitiveMode_TriangleList,
nzPrimitiveMode_TriangleStrip,
nzPrimitiveMode_TriangleFan,
enum TextAlign
{
TextAlign_Left,
TextAlign_Middle,
TextAlign_Right,
nzPrimitiveMode_Max = nzPrimitiveMode_TriangleFan
};
TextAlign_Max = TextAlign_Right
};
enum nzTextAlign
{
nzTextAlign_Left,
nzTextAlign_Middle,
nzTextAlign_Right,
enum TextStyleFlags
{
TextStyle_Regular = 0x0,
nzTextAlign_Max = nzTextAlign_Right
};
TextStyle_Bold = 0x1,
TextStyle_Italic = 0x2,
TextStyle_StrikeThrough = 0x4,
TextStyle_Underlined = 0x8,
enum nzTextStyleFlags
{
nzTextStyle_Regular = 0x0,
TextStyle_Max = TextStyle_Underlined*2-1
};
nzTextStyle_Bold = 0x1,
nzTextStyle_Italic = 0x2,
nzTextStyle_StrikeThrough = 0x4,
nzTextStyle_Underlined = 0x8,
enum VertexComponent
{
VertexComponent_Unused = -1,
nzTextStyle_Max = nzTextStyle_Underlined*2-1
};
// Nous nous limitons à 16 composants de sommets car c'est le minimum supporté par le GPU
VertexComponent_InstanceData0,
VertexComponent_InstanceData1,
VertexComponent_InstanceData2,
VertexComponent_InstanceData3,
VertexComponent_InstanceData4,
VertexComponent_InstanceData5,
VertexComponent_Color,
VertexComponent_Normal,
VertexComponent_Position,
VertexComponent_Tangent,
VertexComponent_TexCoord,
VertexComponent_Userdata0,
VertexComponent_Userdata1,
VertexComponent_Userdata2,
VertexComponent_Userdata3,
VertexComponent_Userdata4,
enum nzVertexComponent
{
nzVertexComponent_Unused = -1,
VertexComponent_FirstInstanceData = VertexComponent_InstanceData0,
VertexComponent_FirstVertexData = VertexComponent_Color,
VertexComponent_LastInstanceData = VertexComponent_InstanceData5,
VertexComponent_LastVertexData = VertexComponent_Userdata4,
// Nous nous limitons à 16 composants de sommets car c'est le minimum supporté par le GPU
nzVertexComponent_InstanceData0,
nzVertexComponent_InstanceData1,
nzVertexComponent_InstanceData2,
nzVertexComponent_InstanceData3,
nzVertexComponent_InstanceData4,
nzVertexComponent_InstanceData5,
nzVertexComponent_Color,
nzVertexComponent_Normal,
nzVertexComponent_Position,
nzVertexComponent_Tangent,
nzVertexComponent_TexCoord,
nzVertexComponent_Userdata0,
nzVertexComponent_Userdata1,
nzVertexComponent_Userdata2,
nzVertexComponent_Userdata3,
nzVertexComponent_Userdata4,
VertexComponent_Max = VertexComponent_Userdata4
};
nzVertexComponent_FirstInstanceData = nzVertexComponent_InstanceData0,
nzVertexComponent_FirstVertexData = nzVertexComponent_Color,
nzVertexComponent_LastInstanceData = nzVertexComponent_InstanceData5,
nzVertexComponent_LastVertexData = nzVertexComponent_Userdata4,
enum VertexLayout
{
// Déclarations destinées au rendu
VertexLayout_XY,
VertexLayout_XY_Color,
VertexLayout_XY_UV,
VertexLayout_XYZ,
VertexLayout_XYZ_Color,
VertexLayout_XYZ_Color_UV,
VertexLayout_XYZ_Normal,
VertexLayout_XYZ_Normal_UV,
VertexLayout_XYZ_Normal_UV_Tangent,
VertexLayout_XYZ_Normal_UV_Tangent_Skinning,
VertexLayout_XYZ_UV,
nzVertexComponent_Max = nzVertexComponent_Userdata4
};
// Déclarations destinées à l'instancing
VertexLayout_Matrix4,
enum nzVertexLayout
{
// Déclarations destinées au rendu
nzVertexLayout_XY,
nzVertexLayout_XY_Color,
nzVertexLayout_XY_UV,
nzVertexLayout_XYZ,
nzVertexLayout_XYZ_Color,
nzVertexLayout_XYZ_Color_UV,
nzVertexLayout_XYZ_Normal,
nzVertexLayout_XYZ_Normal_UV,
nzVertexLayout_XYZ_Normal_UV_Tangent,
nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning,
nzVertexLayout_XYZ_UV,
VertexLayout_Max = VertexLayout_Matrix4
};
// Déclarations destinées à l'instancing
nzVertexLayout_Matrix4,
enum WindowCursor
{
WindowCursor_None,
WindowCursor_Default,
nzVertexLayout_Max = nzVertexLayout_Matrix4
};
WindowCursor_Crosshair,
WindowCursor_Hand,
WindowCursor_Help,
WindowCursor_Move,
WindowCursor_Pointer,
WindowCursor_Progress,
WindowCursor_ResizeE,
WindowCursor_ResizeN,
WindowCursor_ResizeNE,
WindowCursor_ResizeNW,
WindowCursor_ResizeS,
WindowCursor_ResizeSE,
WindowCursor_ResizeSW,
WindowCursor_ResizeW,
WindowCursor_Text,
WindowCursor_Wait,
enum nzWindowCursor
{
nzWindowCursor_None,
nzWindowCursor_Default,
WindowCursor_Max = WindowCursor_Wait
};
nzWindowCursor_Crosshair,
nzWindowCursor_Hand,
nzWindowCursor_Help,
nzWindowCursor_Move,
nzWindowCursor_Pointer,
nzWindowCursor_Progress,
nzWindowCursor_ResizeE,
nzWindowCursor_ResizeN,
nzWindowCursor_ResizeNE,
nzWindowCursor_ResizeNW,
nzWindowCursor_ResizeS,
nzWindowCursor_ResizeSE,
nzWindowCursor_ResizeSW,
nzWindowCursor_ResizeW,
nzWindowCursor_Text,
nzWindowCursor_Wait,
enum WindowEventType
{
WindowEventType_GainedFocus,
WindowEventType_LostFocus,
WindowEventType_KeyPressed,
WindowEventType_KeyReleased,
WindowEventType_MouseButtonDoubleClicked,
WindowEventType_MouseButtonPressed,
WindowEventType_MouseButtonReleased,
WindowEventType_MouseEntered,
WindowEventType_MouseLeft,
WindowEventType_MouseMoved,
WindowEventType_MouseWheelMoved,
WindowEventType_Moved,
WindowEventType_Quit,
WindowEventType_Resized,
WindowEventType_TextEntered,
nzWindowCursor_Max = nzWindowCursor_Wait
};
WindowEventType_Max = WindowEventType_TextEntered
};
enum nzWindowStyleFlags
{
nzWindowStyle_None = 0x0,
nzWindowStyle_Fullscreen = 0x1,
enum WindowStyleFlags
{
WindowStyle_None = 0x0,
WindowStyle_Fullscreen = 0x1,
nzWindowStyle_Closable = 0x2,
nzWindowStyle_Resizable = 0x4,
nzWindowStyle_Titlebar = 0x8,
WindowStyle_Closable = 0x2,
WindowStyle_Resizable = 0x4,
WindowStyle_Titlebar = 0x8,
nzWindowStyle_Default = nzWindowStyle_Closable | nzWindowStyle_Resizable | nzWindowStyle_Titlebar,
nzWindowStyle_Max = nzWindowStyle_Titlebar*2-1
};
WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar,
WindowStyle_Max = WindowStyle_Titlebar*2-1
};
}
#endif // NAZARA_ENUMS_UTILITY_HPP

View File

@@ -13,106 +13,109 @@
#include <Nazara/Utility/Keyboard.hpp>
#include <Nazara/Utility/Mouse.hpp>
struct NzEvent
namespace Nz
{
// Utilisé par:
// -nzEventType_KeyPressed
// -nzEventType_KeyReleased
struct KeyEvent
{
NzKeyboard::Key code;
bool alt;
bool control;
bool repeated;
bool shift;
bool system;
};
// Utilisé par:
// -nzEventType_MouseButtonDoubleClicked
// -nzEventType_MouseButtonPressed
struct MouseButtonEvent
{
NzMouse::Button button;
unsigned int x;
unsigned int y;
};
// Utilisé par:
// -nzEventType_MouseMoved
struct MouseMoveEvent
{
int deltaX;
int deltaY;
unsigned int x;
unsigned int y;
};
// Utilisé par:
// -nzEventType_MouseWheelMoved
struct MouseWheelEvent
{
float delta;
};
// Utilisé par:
// -nzEventType_Moved
struct PositionEvent
{
int x;
int y;
};
// Utilisé par:
// -nzEventType_Resized
struct SizeEvent
{
unsigned int height;
unsigned int width;
};
// Utilisé par:
// -nzEventType_TextEntered
struct TextEvent
{
bool repeated;
char32_t character;
};
nzEventType type;
union
struct WindowEvent
{
// Utilisé par:
// -nzEventType_KeyPressed
// -nzEventType_KeyReleased
KeyEvent key;
// -WindowEventType_KeyPressed
// -WindowEventType_KeyReleased
struct KeyEvent
{
Keyboard::Key code;
bool alt;
bool control;
bool repeated;
bool shift;
bool system;
};
// Utilisé par:
// -nzEventType_MouseButtonDoubleClicked
// -nzEventType_MouseButtonPressed
MouseButtonEvent mouseButton;
// -WindowEventType_MouseButtonDoubleClicked
// -WindowEventType_MouseButtonPressed
struct MouseButtonEvent
{
Mouse::Button button;
unsigned int x;
unsigned int y;
};
// Utilisé par:
// -nzEventType_MouseMoved
MouseMoveEvent mouseMove;
// -WindowEventType_MouseMoved
struct MouseMoveEvent
{
int deltaX;
int deltaY;
unsigned int x;
unsigned int y;
};
// Utilisé par:
// -nzEventType_MouseWheelMoved
MouseWheelEvent mouseWheel;
// -WindowEventType_MouseWheelMoved
struct MouseWheelEvent
{
float delta;
};
// Utilisé par:
// -nzEventType_Moved
PositionEvent position;
// -WindowEventType_Moved
struct PositionEvent
{
int x;
int y;
};
// Utilisé par:
// -nzEventType_Resized
SizeEvent size;
// -WindowEventType_Resized
struct SizeEvent
{
unsigned int height;
unsigned int width;
};
// Utilisé par:
// -nzEventType_TextEntered
TextEvent text;
// -WindowEventType_TextEntered
struct TextEvent
{
bool repeated;
char32_t character;
};
WindowEventType type;
union
{
// Utilisé par:
// -WindowEventType_KeyPressed
// -WindowEventType_KeyReleased
KeyEvent key;
// Utilisé par:
// -WindowEventType_MouseButtonDoubleClicked
// -WindowEventType_MouseButtonPressed
MouseButtonEvent mouseButton;
// Utilisé par:
// -WindowEventType_MouseMoved
MouseMoveEvent mouseMove;
// Utilisé par:
// -WindowEventType_MouseWheelMoved
MouseWheelEvent mouseWheel;
// Utilisé par:
// -WindowEventType_Moved
PositionEvent position;
// Utilisé par:
// -WindowEventType_Resized
SizeEvent size;
// Utilisé par:
// -WindowEventType_TextEntered
TextEvent text;
};
};
};
}
#endif // NAZARA_EVENT_HPP

View File

@@ -18,144 +18,147 @@
#include <memory>
#include <unordered_map>
struct NAZARA_UTILITY_API NzFontParams
namespace Nz
{
bool IsValid() const;
};
class NzFont;
class NzFontData;
struct NzFontGlyph;
using NzFontConstRef = NzObjectRef<const NzFont>;
using NzFontLibrary = NzObjectLibrary<NzFont>;
using NzFontLoader = NzResourceLoader<NzFont, NzFontParams>;
using NzFontRef = NzObjectRef<NzFont>;
class NAZARA_UTILITY_API NzFont : public NzRefCounted, public NzResource
{
friend NzFontLibrary;
friend NzFontLoader;
friend class NzUtility;
public:
struct Glyph;
struct SizeInfo;
NzFont();
NzFont(const NzFont&) = delete;
NzFont(NzFont&&) = delete;
~NzFont();
void ClearGlyphCache();
void ClearKerningCache();
void ClearSizeInfoCache();
bool Create(NzFontData* data);
void Destroy();
bool ExtractGlyph(unsigned int characterSize, char32_t character, nzUInt32 style, NzFontGlyph* glyph) const;
const std::shared_ptr<NzAbstractAtlas>& GetAtlas() const;
unsigned int GetCachedGlyphCount(unsigned int characterSize, nzUInt32 style) const;
unsigned int GetCachedGlyphCount() const;
NzString GetFamilyName() const;
int GetKerning(unsigned int characterSize, char32_t first, char32_t second) const;
const Glyph& GetGlyph(unsigned int characterSize, nzUInt32 style, char32_t character) const;
unsigned int GetGlyphBorder() const;
unsigned int GetMinimumStepSize() const;
const SizeInfo& GetSizeInfo(unsigned int characterSize) const;
NzString GetStyleName() const;
struct NAZARA_UTILITY_API FontParams
{
bool IsValid() const;
};
bool Precache(unsigned int characterSize, nzUInt32 style, char32_t character) const;
bool Precache(unsigned int characterSize, nzUInt32 style, const NzString& characterSet) const;
class Font;
class FontData;
// Open
bool OpenFromFile(const NzString& filePath, const NzFontParams& params = NzFontParams());
bool OpenFromMemory(const void* data, std::size_t size, const NzFontParams& params = NzFontParams());
bool OpenFromStream(NzInputStream& stream, const NzFontParams& params = NzFontParams());
struct FontGlyph;
void SetAtlas(const std::shared_ptr<NzAbstractAtlas>& atlas);
void SetGlyphBorder(unsigned int borderSize);
void SetMinimumStepSize(unsigned int minimumStepSize);
using FontConstRef = ObjectRef<const Font>;
using FontLibrary = ObjectLibrary<Font>;
using FontLoader = ResourceLoader<Font, FontParams>;
using FontRef = ObjectRef<Font>;
NzFont& operator=(const NzFont&) = delete;
NzFont& operator=(NzFont&&) = delete;
class NAZARA_UTILITY_API Font : public RefCounted, public Resource
{
friend FontLibrary;
friend FontLoader;
friend class Utility;
static std::shared_ptr<NzAbstractAtlas> GetDefaultAtlas();
static NzFont* GetDefault();
static unsigned int GetDefaultGlyphBorder();
static unsigned int GetDefaultMinimumStepSize();
public:
struct Glyph;
struct SizeInfo;
template<typename... Args> static NzFontRef New(Args&&... args);
Font();
Font(const Font&) = delete;
Font(Font&&) = delete;
~Font();
static void SetDefaultAtlas(const std::shared_ptr<NzAbstractAtlas>& atlas);
static void SetDefaultGlyphBorder(unsigned int borderSize);
static void SetDefaultMinimumStepSize(unsigned int minimumStepSize);
void ClearGlyphCache();
void ClearKerningCache();
void ClearSizeInfoCache();
struct Glyph
{
NzRecti aabb;
NzRectui atlasRect;
bool requireFauxBold;
bool requireFauxItalic;
bool flipped;
bool valid;
int advance;
unsigned int layerIndex;
};
bool Create(FontData* data);
void Destroy();
struct SizeInfo
{
int spaceAdvance;
unsigned int lineHeight;
float underlinePosition;
float underlineThickness;
};
bool ExtractGlyph(unsigned int characterSize, char32_t character, UInt32 style, FontGlyph* glyph) const;
// Signals:
NazaraSignal(OnFontAtlasChanged, const NzFont* /*font*/);
NazaraSignal(OnFontAtlasLayerChanged, const NzFont* /*font*/, NzAbstractImage* /*oldLayer*/, NzAbstractImage* /*newLayer*/);
NazaraSignal(OnFontDestroy, const NzFont* /*font*/);
NazaraSignal(OnFontGlyphCacheCleared, const NzFont* /*font*/);
NazaraSignal(OnFontKerningCacheCleared, const NzFont* /*font*/);
NazaraSignal(OnFontRelease, const NzFont* /*font*/);
NazaraSignal(OnFontSizeInfoCacheCleared, const NzFont* /*font*/);
const std::shared_ptr<AbstractAtlas>& GetAtlas() const;
unsigned int GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const;
unsigned int GetCachedGlyphCount() const;
String GetFamilyName() const;
int GetKerning(unsigned int characterSize, char32_t first, char32_t second) const;
const Glyph& GetGlyph(unsigned int characterSize, UInt32 style, char32_t character) const;
unsigned int GetGlyphBorder() const;
unsigned int GetMinimumStepSize() const;
const SizeInfo& GetSizeInfo(unsigned int characterSize) const;
String GetStyleName() const;
private:
using GlyphMap = std::unordered_map<char32_t, Glyph>;
bool IsValid() const;
nzUInt64 ComputeKey(unsigned int characterSize, nzUInt32 style) const;
void OnAtlasCleared(const NzAbstractAtlas* atlas);
void OnAtlasLayerChange(const NzAbstractAtlas* atlas, NzAbstractImage* oldLayer, NzAbstractImage* newLayer);
void OnAtlasRelease(const NzAbstractAtlas* atlas);
const Glyph& PrecacheGlyph(GlyphMap& glyphMap, unsigned int characterSize, nzUInt32 style, char32_t character) const;
bool Precache(unsigned int characterSize, UInt32 style, char32_t character) const;
bool Precache(unsigned int characterSize, UInt32 style, const String& characterSet) const;
static bool Initialize();
static void Uninitialize();
// Open
bool OpenFromFile(const String& filePath, const FontParams& params = FontParams());
bool OpenFromMemory(const void* data, std::size_t size, const FontParams& params = FontParams());
bool OpenFromStream(InputStream& stream, const FontParams& params = FontParams());
NazaraSlot(NzAbstractAtlas, OnAtlasCleared, m_atlasClearedSlot);
NazaraSlot(NzAbstractAtlas, OnAtlasLayerChange, m_atlasLayerChangeSlot);
NazaraSlot(NzAbstractAtlas, OnAtlasRelease, m_atlasReleaseSlot);
void SetAtlas(const std::shared_ptr<AbstractAtlas>& atlas);
void SetGlyphBorder(unsigned int borderSize);
void SetMinimumStepSize(unsigned int minimumStepSize);
std::shared_ptr<NzAbstractAtlas> m_atlas;
std::unique_ptr<NzFontData> m_data;
mutable std::unordered_map<nzUInt64, std::unordered_map<nzUInt64, int>> m_kerningCache;
mutable std::unordered_map<nzUInt64, GlyphMap> m_glyphes;
mutable std::unordered_map<nzUInt64, SizeInfo> m_sizeInfoCache;
unsigned int m_glyphBorder;
unsigned int m_minimumStepSize;
Font& operator=(const Font&) = delete;
Font& operator=(Font&&) = delete;
static std::shared_ptr<NzAbstractAtlas> s_defaultAtlas;
static NzFontRef s_defaultFont;
static NzFontLibrary::LibraryMap s_library;
static NzFontLoader::LoaderList s_loaders;
static unsigned int s_defaultGlyphBorder;
static unsigned int s_defaultMinimumStepSize;
};
static std::shared_ptr<AbstractAtlas> GetDefaultAtlas();
static Font* GetDefault();
static unsigned int GetDefaultGlyphBorder();
static unsigned int GetDefaultMinimumStepSize();
template<typename... Args> static FontRef New(Args&&... args);
static void SetDefaultAtlas(const std::shared_ptr<AbstractAtlas>& atlas);
static void SetDefaultGlyphBorder(unsigned int borderSize);
static void SetDefaultMinimumStepSize(unsigned int minimumStepSize);
struct Glyph
{
Recti aabb;
Rectui atlasRect;
bool requireFauxBold;
bool requireFauxItalic;
bool flipped;
bool valid;
int advance;
unsigned int layerIndex;
};
struct SizeInfo
{
int spaceAdvance;
unsigned int lineHeight;
float underlinePosition;
float underlineThickness;
};
// Signals:
NazaraSignal(OnFontAtlasChanged, const Font* /*font*/);
NazaraSignal(OnFontAtlasLayerChanged, const Font* /*font*/, AbstractImage* /*oldLayer*/, AbstractImage* /*newLayer*/);
NazaraSignal(OnFontDestroy, const Font* /*font*/);
NazaraSignal(OnFontGlyphCacheCleared, const Font* /*font*/);
NazaraSignal(OnFontKerningCacheCleared, const Font* /*font*/);
NazaraSignal(OnFontRelease, const Font* /*font*/);
NazaraSignal(OnFontSizeInfoCacheCleared, const Font* /*font*/);
private:
using GlyphMap = std::unordered_map<char32_t, Glyph>;
UInt64 ComputeKey(unsigned int characterSize, UInt32 style) const;
void OnAtlasCleared(const AbstractAtlas* atlas);
void OnAtlasLayerChange(const AbstractAtlas* atlas, AbstractImage* oldLayer, AbstractImage* newLayer);
void OnAtlasRelease(const AbstractAtlas* atlas);
const Glyph& PrecacheGlyph(GlyphMap& glyphMap, unsigned int characterSize, UInt32 style, char32_t character) const;
static bool Initialize();
static void Uninitialize();
NazaraSlot(AbstractAtlas, OnAtlasCleared, m_atlasClearedSlot);
NazaraSlot(AbstractAtlas, OnAtlasLayerChange, m_atlasLayerChangeSlot);
NazaraSlot(AbstractAtlas, OnAtlasRelease, m_atlasReleaseSlot);
std::shared_ptr<AbstractAtlas> m_atlas;
std::unique_ptr<FontData> m_data;
mutable std::unordered_map<UInt64, std::unordered_map<UInt64, int>> m_kerningCache;
mutable std::unordered_map<UInt64, GlyphMap> m_glyphes;
mutable std::unordered_map<UInt64, SizeInfo> m_sizeInfoCache;
unsigned int m_glyphBorder;
unsigned int m_minimumStepSize;
static std::shared_ptr<AbstractAtlas> s_defaultAtlas;
static FontRef s_defaultFont;
static FontLibrary::LibraryMap s_library;
static FontLoader::LoaderList s_loaders;
static unsigned int s_defaultGlyphBorder;
static unsigned int s_defaultMinimumStepSize;
};
}
#include <Nazara/Utility/Font.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzFontRef NzFont::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzFont> object(new NzFont(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
FontRef Font::New(Args&&... args)
{
std::unique_ptr<Font> object(new Font(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -11,29 +11,32 @@
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Config.hpp>
struct NzFontGlyph;
class NAZARA_UTILITY_API NzFontData
namespace Nz
{
public:
NzFontData() = default;
virtual ~NzFontData();
struct FontGlyph;
virtual bool ExtractGlyph(unsigned int characterSize, char32_t character, nzUInt32 style, NzFontGlyph* dst) = 0;
class NAZARA_UTILITY_API FontData
{
public:
FontData() = default;
virtual ~FontData();
virtual NzString GetFamilyName() const = 0;
virtual NzString GetStyleName() const = 0;
virtual bool ExtractGlyph(unsigned int characterSize, char32_t character, UInt32 style, FontGlyph* dst) = 0;
virtual bool HasKerning() const = 0;
virtual String GetFamilyName() const = 0;
virtual String GetStyleName() const = 0;
virtual bool IsScalable() const = 0;
virtual bool HasKerning() const = 0;
virtual int QueryKerning(unsigned int characterSize, char32_t first, char32_t second) const = 0;
virtual unsigned int QueryLineHeight(unsigned int characterSize) const = 0;
virtual float QueryUnderlinePosition(unsigned int characterSize) const = 0;
virtual float QueryUnderlineThickness(unsigned int characterSize) const = 0;
virtual bool IsScalable() const = 0;
virtual bool SupportsStyle(nzUInt32 style) const = 0;
};
virtual int QueryKerning(unsigned int characterSize, char32_t first, char32_t second) const = 0;
virtual unsigned int QueryLineHeight(unsigned int characterSize) const = 0;
virtual float QueryUnderlinePosition(unsigned int characterSize) const = 0;
virtual float QueryUnderlineThickness(unsigned int characterSize) const = 0;
virtual bool SupportsStyle(UInt32 style) const = 0;
};
}
#endif // NAZARA_FONTDATA_HPP

View File

@@ -9,11 +9,14 @@
#include <Nazara/Utility/Image.hpp>
struct NzFontGlyph
namespace Nz
{
NzImage image;
NzRecti aabb;
int advance;
};
struct FontGlyph
{
Image image;
Recti aabb;
int advance;
};
}
#endif // NAZARA_FONTGLYPH_HPP

View File

@@ -15,65 +15,68 @@
#include <Nazara/Utility/Animation.hpp>
#include <vector>
class NAZARA_UTILITY_API NzMD5AnimParser
namespace Nz
{
public:
struct FrameJoint
{
NzQuaternionf orient;
NzVector3f pos;
};
class NAZARA_UTILITY_API MD5AnimParser
{
public:
struct FrameJoint
{
Quaternionf orient;
Vector3f pos;
};
struct Frame
{
std::vector<FrameJoint> joints;
NzBoxf bounds;
};
struct Frame
{
std::vector<FrameJoint> joints;
Boxf bounds;
};
struct Joint
{
NzQuaternionf bindOrient;
NzString name;
NzVector3f bindPos;
int parent;
unsigned int flags;
unsigned int index;
};
struct Joint
{
Quaternionf bindOrient;
String name;
Vector3f bindPos;
int parent;
unsigned int flags;
unsigned int index;
};
NzMD5AnimParser(NzInputStream& stream);
~NzMD5AnimParser();
MD5AnimParser(InputStream& stream);
~MD5AnimParser();
nzTernary Check();
Ternary Check();
unsigned int GetAnimatedComponentCount() const;
const Frame* GetFrames() const;
unsigned int GetFrameCount() const;
unsigned int GetFrameRate() const;
const Joint* GetJoints() const;
unsigned int GetJointCount() const;
unsigned int GetAnimatedComponentCount() const;
const Frame* GetFrames() const;
unsigned int GetFrameCount() const;
unsigned int GetFrameRate() const;
const Joint* GetJoints() const;
unsigned int GetJointCount() const;
bool Parse();
bool Parse();
private:
bool Advance(bool required = true);
void Error(const NzString& message);
bool ParseBaseframe();
bool ParseBounds();
bool ParseFrame();
bool ParseHierarchy();
void Warning(const NzString& message);
void UnrecognizedLine(bool error = false);
private:
bool Advance(bool required = true);
void Error(const String& message);
bool ParseBaseframe();
bool ParseBounds();
bool ParseFrame();
bool ParseHierarchy();
void Warning(const String& message);
void UnrecognizedLine(bool error = false);
std::vector<float> m_animatedComponents;
std::vector<Frame> m_frames;
std::vector<Joint> m_joints;
NzInputStream& m_stream;
NzString m_currentLine;
bool m_keepLastLine;
unsigned int m_frameIndex;
unsigned int m_frameRate;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
std::vector<float> m_animatedComponents;
std::vector<Frame> m_frames;
std::vector<Joint> m_joints;
InputStream& m_stream;
String m_currentLine;
bool m_keepLastLine;
unsigned int m_frameIndex;
unsigned int m_frameRate;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
}
#endif // NAZARA_FORMATS_MD5ANIMPARSER_HPP

View File

@@ -15,69 +15,72 @@
#include <Nazara/Utility/Mesh.hpp>
#include <vector>
class NAZARA_UTILITY_API NzMD5MeshParser
namespace Nz
{
public:
struct Joint
{
NzQuaternionf bindOrient;
NzString name;
NzVector3f bindPos;
int parent;
};
class NAZARA_UTILITY_API MD5MeshParser
{
public:
struct Joint
{
Quaternionf bindOrient;
String name;
Vector3f bindPos;
int parent;
};
typedef NzVector3ui Triangle;
typedef Vector3ui Triangle;
struct Vertex
{
NzVector2f uv;
unsigned int startWeight;
unsigned int weightCount;
};
struct Vertex
{
Vector2f uv;
unsigned int startWeight;
unsigned int weightCount;
};
struct Weight
{
NzVector3f pos;
float bias;
unsigned int joint;
};
struct Weight
{
Vector3f pos;
float bias;
unsigned int joint;
};
struct Mesh
{
std::vector<Triangle> triangles;
std::vector<Vertex> vertices;
std::vector<Weight> weights;
NzString shader;
};
struct Mesh
{
std::vector<Triangle> triangles;
std::vector<Vertex> vertices;
std::vector<Weight> weights;
String shader;
};
NzMD5MeshParser(NzInputStream& stream);
~NzMD5MeshParser();
MD5MeshParser(InputStream& stream);
~MD5MeshParser();
nzTernary Check();
Ternary Check();
const Joint* GetJoints() const;
unsigned int GetJointCount() const;
const Mesh* GetMeshes() const;
unsigned int GetMeshCount() const;
const Joint* GetJoints() const;
unsigned int GetJointCount() const;
const Mesh* GetMeshes() const;
unsigned int GetMeshCount() const;
bool Parse();
bool Parse();
private:
bool Advance(bool required = true);
void Error(const NzString& message);
bool ParseJoints();
bool ParseMesh();
void Warning(const NzString& message);
void UnrecognizedLine(bool error = false);
private:
bool Advance(bool required = true);
void Error(const String& message);
bool ParseJoints();
bool ParseMesh();
void Warning(const String& message);
void UnrecognizedLine(bool error = false);
std::vector<Joint> m_joints;
std::vector<Mesh> m_meshes;
NzInputStream& m_stream;
NzString m_currentLine;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_meshIndex;
unsigned int m_streamFlags;
};
std::vector<Joint> m_joints;
std::vector<Mesh> m_meshes;
InputStream& m_stream;
String m_currentLine;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_meshIndex;
unsigned int m_streamFlags;
};
}
#endif // NAZARA_FORMATS_MD5MESHPARSER_HPP

View File

@@ -14,49 +14,52 @@
#include <Nazara/Utility/Config.hpp>
#include <unordered_map>
class NAZARA_UTILITY_API NzMTLParser
namespace Nz
{
public:
struct Material
{
NzColor ambient = NzColor::White;
NzColor diffuse = NzColor::White;
NzColor specular = NzColor::White;
NzString alphaMap;
NzString ambientMap;
NzString bumpMap;
NzString decalMap;
NzString diffuseMap;
NzString displacementMap;
NzString reflectionMap;
NzString shininessMap;
NzString specularMap;
float alpha = 1.f;
float refractionIndex = 1.f;
float shininess = 1.f;
unsigned int illumModel = 0;
};
class NAZARA_UTILITY_API MTLParser
{
public:
struct Material
{
Color ambient = Color::White;
Color diffuse = Color::White;
Color specular = Color::White;
String alphaMap;
String ambientMap;
String bumpMap;
String decalMap;
String diffuseMap;
String displacementMap;
String reflectionMap;
String shininessMap;
String specularMap;
float alpha = 1.f;
float refractionIndex = 1.f;
float shininess = 1.f;
unsigned int illumModel = 0;
};
NzMTLParser(NzInputStream& stream$);
~NzMTLParser();
MTLParser(InputStream& stream$);
~MTLParser();
const Material* GetMaterial(const NzString& materialName) const;
const std::unordered_map<NzString, Material>& GetMaterials() const;
const Material* GetMaterial(const String& materialName) const;
const std::unordered_map<String, Material>& GetMaterials() const;
bool Parse();
bool Parse();
private:
bool Advance(bool required = true);
void Error(const NzString& message);
void Warning(const NzString& message);
void UnrecognizedLine(bool error = false);
private:
bool Advance(bool required = true);
void Error(const String& message);
void Warning(const String& message);
void UnrecognizedLine(bool error = false);
std::unordered_map<NzString, Material> m_materials;
NzInputStream& m_stream;
NzString m_currentLine;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
std::unordered_map<String, Material> m_materials;
InputStream& m_stream;
String m_currentLine;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
}
#endif // NAZARA_FORMATS_MTLPARSER_HPP

View File

@@ -15,62 +15,65 @@
#include <Nazara/Utility/Config.hpp>
#include <vector>
class NAZARA_UTILITY_API NzOBJParser
namespace Nz
{
public:
struct FaceVertex
{
int normal;
int position;
int texCoord;
};
class NAZARA_UTILITY_API OBJParser
{
public:
struct FaceVertex
{
int normal;
int position;
int texCoord;
};
struct Face
{
std::vector<FaceVertex> vertices;
};
struct Face
{
std::vector<FaceVertex> vertices;
};
struct Mesh
{
std::vector<Face> faces;
NzString name;
unsigned int material;
};
struct Mesh
{
std::vector<Face> faces;
String name;
unsigned int material;
};
NzOBJParser(NzInputStream& stream$);
~NzOBJParser();
OBJParser(InputStream& stream$);
~OBJParser();
const NzString* GetMaterials() const;
unsigned int GetMaterialCount() const;
const Mesh* GetMeshes() const;
unsigned int GetMeshCount() const;
const NzString& GetMtlLib() const;
const NzVector3f* GetNormals() const;
unsigned int GetNormalCount() const;
const NzVector4f* GetPositions() const;
unsigned int GetPositionCount() const;
const NzVector3f* GetTexCoords() const;
unsigned int GetTexCoordCount() const;
const String* GetMaterials() const;
unsigned int GetMaterialCount() const;
const Mesh* GetMeshes() const;
unsigned int GetMeshCount() const;
const String& GetMtlLib() const;
const Vector3f* GetNormals() const;
unsigned int GetNormalCount() const;
const Vector4f* GetPositions() const;
unsigned int GetPositionCount() const;
const Vector3f* GetTexCoords() const;
unsigned int GetTexCoordCount() const;
bool Parse();
bool Parse();
private:
bool Advance(bool required = true);
void Error(const NzString& message);
void Warning(const NzString& message);
void UnrecognizedLine(bool error = false);
private:
bool Advance(bool required = true);
void Error(const String& message);
void Warning(const String& message);
void UnrecognizedLine(bool error = false);
std::vector<Mesh> m_meshes;
std::vector<NzString> m_materials;
std::vector<NzVector3f> m_normals;
std::vector<NzVector4f> m_positions;
std::vector<NzVector3f> m_texCoords;
NzInputStream& m_stream;
NzString m_currentLine;
NzString m_mtlLib;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
std::vector<Mesh> m_meshes;
std::vector<String> m_materials;
std::vector<Vector3f> m_normals;
std::vector<Vector4f> m_positions;
std::vector<Vector3f> m_texCoords;
InputStream& m_stream;
String m_currentLine;
String m_mtlLib;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
}
#endif // NAZARA_FORMATS_OBJPARSER_HPP

View File

@@ -15,53 +15,56 @@
#include <memory>
#include <vector>
class NAZARA_UTILITY_API NzGuillotineImageAtlas : public NzAbstractAtlas
namespace Nz
{
public:
NzGuillotineImageAtlas();
virtual ~NzGuillotineImageAtlas();
class NAZARA_UTILITY_API GuillotineImageAtlas : public AbstractAtlas
{
public:
GuillotineImageAtlas();
virtual ~GuillotineImageAtlas();
void Clear();
void Free(NzSparsePtr<const NzRectui> rects, NzSparsePtr<unsigned int> layers, unsigned int count);
void Clear();
void Free(SparsePtr<const Rectui> rects, SparsePtr<unsigned int> layers, unsigned int count);
NzGuillotineBinPack::FreeRectChoiceHeuristic GetRectChoiceHeuristic() const;
NzGuillotineBinPack::GuillotineSplitHeuristic GetRectSplitHeuristic() const;
NzAbstractImage* GetLayer(unsigned int layerIndex) const;
unsigned int GetLayerCount() const;
nzUInt32 GetStorage() const;
GuillotineBinPack::FreeRectChoiceHeuristic GetRectChoiceHeuristic() const;
GuillotineBinPack::GuillotineSplitHeuristic GetRectSplitHeuristic() const;
AbstractImage* GetLayer(unsigned int layerIndex) const;
unsigned int GetLayerCount() const;
UInt32 GetStorage() const;
bool Insert(const NzImage& image, NzRectui* rect, bool* flipped, unsigned int* layerIndex);
bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex);
void SetRectChoiceHeuristic(NzGuillotineBinPack::FreeRectChoiceHeuristic heuristic);
void SetRectSplitHeuristic(NzGuillotineBinPack::GuillotineSplitHeuristic heuristic);
void SetRectChoiceHeuristic(GuillotineBinPack::FreeRectChoiceHeuristic heuristic);
void SetRectSplitHeuristic(GuillotineBinPack::GuillotineSplitHeuristic heuristic);
protected:
struct Layer;
protected:
struct Layer;
virtual NzAbstractImage* ResizeImage(NzAbstractImage* oldImage, const NzVector2ui& size) const;
bool ResizeLayer(Layer& layer, const NzVector2ui& size);
virtual AbstractImage* ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const;
bool ResizeLayer(Layer& layer, const Vector2ui& size);
struct QueuedGlyph
{
NzImage image;
NzRectui rect;
bool flipped;
};
struct QueuedGlyph
{
Image image;
Rectui rect;
bool flipped;
};
struct Layer
{
std::vector<QueuedGlyph> queuedGlyphs;
std::unique_ptr<NzAbstractImage> image;
NzGuillotineBinPack binPack;
unsigned int freedRectangles = 0;
};
struct Layer
{
std::vector<QueuedGlyph> queuedGlyphs;
std::unique_ptr<AbstractImage> image;
GuillotineBinPack binPack;
unsigned int freedRectangles = 0;
};
private:
void ProcessGlyphQueue(Layer& layer) const;
private:
void ProcessGlyphQueue(Layer& layer) const;
mutable std::vector<Layer> m_layers;
NzGuillotineBinPack::FreeRectChoiceHeuristic m_rectChoiceHeuristic;
NzGuillotineBinPack::GuillotineSplitHeuristic m_rectSplitHeuristic;
};
mutable std::vector<Layer> m_layers;
GuillotineBinPack::FreeRectChoiceHeuristic m_rectChoiceHeuristic;
GuillotineBinPack::GuillotineSplitHeuristic m_rectSplitHeuristic;
};
}
#endif // NAZARA_GUILLOTINEIMAGEATLAS_HPP

View File

@@ -11,24 +11,27 @@
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Utility/Config.hpp>
class NzImage;
class NzIconImpl;
class NAZARA_UTILITY_API NzIcon
namespace Nz
{
friend class NzWindowImpl;
class Image;
class IconImpl;
public:
NzIcon();
~NzIcon();
class NAZARA_UTILITY_API Icon
{
friend class WindowImpl;
bool Create(const NzImage& icon);
void Destroy();
public:
Icon();
~Icon();
bool IsValid() const;
bool Create(const Image& icon);
void Destroy();
private:
NzIconImpl* m_impl;
};
bool IsValid() const;
private:
IconImpl* m_impl;
};
}
#endif // NAZARA_ICON_HPP

View File

@@ -23,147 +23,150 @@
///TODO: Filtres
struct NAZARA_UTILITY_API NzImageParams
namespace Nz
{
// Le format dans lequel l'image doit être chargée (Undefined pour le format le plus proche de l'original)
nzPixelFormat loadFormat = nzPixelFormat_Undefined;
struct NAZARA_UTILITY_API ImageParams
{
// Le format dans lequel l'image doit être chargée (Undefined pour le format le plus proche de l'original)
PixelFormatType loadFormat = PixelFormatType_Undefined;
// Le nombre de niveaux de mipmaps maximum devant être créé
nzUInt8 levelCount = 0;
bool IsValid() const;
};
class NzImage;
using NzImageConstRef = NzObjectRef<const NzImage>;
using NzImageLibrary = NzObjectLibrary<NzImage>;
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
using NzImageManager = NzResourceManager<NzImage, NzImageParams>;
using NzImageRef = NzObjectRef<NzImage>;
class NAZARA_UTILITY_API NzImage : public NzAbstractImage, public NzRefCounted, public NzResource
{
friend NzImageLibrary;
friend NzImageLoader;
friend NzImageManager;
friend class NzUtility;
public:
struct SharedImage;
NzImage();
NzImage(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
NzImage(const NzImage& image);
NzImage(SharedImage* sharedImage);
~NzImage();
bool Convert(nzPixelFormat format);
void Copy(const NzImage& source, const NzBoxui& srcBox, const NzVector3ui& dstPos);
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
void Destroy();
bool Fill(const NzColor& color);
bool Fill(const NzColor& color, const NzBoxui& box);
bool Fill(const NzColor& color, const NzRectui& rect, unsigned int z = 0);
bool FlipHorizontally();
bool FlipVertically();
const nzUInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, nzUInt8 level = 0) const;
unsigned int GetDepth(nzUInt8 level = 0) const;
nzPixelFormat GetFormat() const;
unsigned int GetHeight(nzUInt8 level = 0) const;
nzUInt8 GetLevelCount() const;
nzUInt8 GetMaxLevel() const;
unsigned int GetMemoryUsage() const;
unsigned int GetMemoryUsage(nzUInt8 level) const;
NzColor GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const;
nzUInt8* GetPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, nzUInt8 level = 0);
NzVector3ui GetSize(nzUInt8 level = 0) const;
nzImageType GetType() const;
unsigned int GetWidth(nzUInt8 level = 0) const;
// Le nombre de niveaux de mipmaps maximum devant être créé
UInt8 levelCount = 0;
bool IsValid() const;
};
// Load
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
class Image;
// LoadArray
bool LoadArrayFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), const NzVector2ui& atlasSize = NzVector2ui(2, 2));
bool LoadArrayFromImage(const NzImage& image, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
bool LoadArrayFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), const NzVector2ui& atlasSize = NzVector2ui(2, 2));
bool LoadArrayFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), const NzVector2ui& atlasSize = NzVector2ui(2, 2));
using ImageConstRef = ObjectRef<const Image>;
using ImageLibrary = ObjectLibrary<Image>;
using ImageLoader = ResourceLoader<Image, ImageParams>;
using ImageManager = ResourceManager<Image, ImageParams>;
using ImageRef = ObjectRef<Image>;
// LoadCubemap
bool LoadCubemapFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), const NzCubemapParams& cubemapParams = NzCubemapParams());
bool LoadCubemapFromImage(const NzImage& image, const NzCubemapParams& params = NzCubemapParams());
bool LoadCubemapFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), const NzCubemapParams& cubemapParams = NzCubemapParams());
bool LoadCubemapFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), const NzCubemapParams& cubemapParams = NzCubemapParams());
class NAZARA_UTILITY_API Image : public AbstractImage, public RefCounted, public Resource
{
friend ImageLibrary;
friend ImageLoader;
friend ImageManager;
friend class Utility;
void SetLevelCount(nzUInt8 levelCount);
bool SetPixelColor(const NzColor& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
public:
struct SharedImage;
bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
Image();
Image(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
Image(const Image& image);
Image(SharedImage* sharedImage);
~Image();
NzImage& operator=(const NzImage& image);
bool Convert(PixelFormatType format);
static void Copy(nzUInt8* destination, const nzUInt8* source, nzUInt8 bpp, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0);
static nzUInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1);
static nzUInt8 GetMaxLevel(nzImageType type, unsigned int width, unsigned int height, unsigned int depth = 1);
template<typename... Args> static NzImageRef New(Args&&... args);
void Copy(const Image& source, const Boxui& srcBox, const Vector3ui& dstPos);
struct SharedImage
{
using PixelContainer = std::vector<std::unique_ptr<nzUInt8[]>>;
bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
void Destroy();
SharedImage(unsigned short RefCount, nzImageType Type, nzPixelFormat Format, PixelContainer&& Levels, unsigned int Width, unsigned int Height, unsigned int Depth) :
type(Type),
format(Format),
levels(std::move(Levels)),
depth(Depth),
height(Height),
width(Width),
refCount(RefCount)
bool Fill(const Color& color);
bool Fill(const Color& color, const Boxui& box);
bool Fill(const Color& color, const Rectui& rect, unsigned int z = 0);
bool FlipHorizontally();
bool FlipVertically();
const UInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0) const;
unsigned int GetDepth(UInt8 level = 0) const;
PixelFormatType GetFormat() const;
unsigned int GetHeight(UInt8 level = 0) const;
UInt8 GetLevelCount() const;
UInt8 GetMaxLevel() const;
unsigned int GetMemoryUsage() const;
unsigned int GetMemoryUsage(UInt8 level) const;
Color GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const;
UInt8* GetPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0);
Vector3ui GetSize(UInt8 level = 0) const;
ImageType GetType() const;
unsigned int GetWidth(UInt8 level = 0) const;
bool IsValid() const;
// Load
bool LoadFromFile(const String& filePath, const ImageParams& params = ImageParams());
bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams());
bool LoadFromStream(InputStream& stream, const ImageParams& params = ImageParams());
// LoadArray
bool LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
bool LoadArrayFromImage(const Image& image, const Vector2ui& atlasSize = Vector2ui(2, 2));
bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
bool LoadArrayFromStream(InputStream& stream, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
// LoadCubemap
bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
bool LoadCubemapFromImage(const Image& image, const CubemapParams& params = CubemapParams());
bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
bool LoadCubemapFromStream(InputStream& stream, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
void SetLevelCount(UInt8 levelCount);
bool SetPixelColor(const Color& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
Image& operator=(const Image& image);
static void Copy(UInt8* destination, const UInt8* source, UInt8 bpp, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0);
static UInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1);
static UInt8 GetMaxLevel(ImageType type, unsigned int width, unsigned int height, unsigned int depth = 1);
template<typename... Args> static ImageRef New(Args&&... args);
struct SharedImage
{
}
using PixelContainer = std::vector<std::unique_ptr<UInt8[]>>;
nzImageType type;
nzPixelFormat format;
PixelContainer levels;
unsigned int depth;
unsigned int height;
unsigned int width;
SharedImage(unsigned short RefCount, ImageType Type, PixelFormatType Format, PixelContainer&& Levels, unsigned int Width, unsigned int Height, unsigned int Depth) :
type(Type),
format(Format),
levels(std::move(Levels)),
depth(Depth),
height(Height),
width(Width),
refCount(RefCount)
{
}
std::atomic_ushort refCount;
ImageType type;
PixelFormatType format;
PixelContainer levels;
unsigned int depth;
unsigned int height;
unsigned int width;
std::atomic_ushort refCount;
};
static SharedImage emptyImage;
// Signals:
NazaraSignal(OnImageDestroy, const Image* /*image*/);
NazaraSignal(OnImageRelease, const Image* /*image*/);
private:
void EnsureOwnership();
void ReleaseImage();
static bool Initialize();
static void Uninitialize();
SharedImage* m_sharedImage;
static ImageLibrary::LibraryMap s_library;
static ImageLoader::LoaderList s_loaders;
static ImageManager::ManagerMap s_managerMap;
static ImageManager::ManagerParams s_managerParameters;
};
static SharedImage emptyImage;
// Signals:
NazaraSignal(OnImageDestroy, const NzImage* /*image*/);
NazaraSignal(OnImageRelease, const NzImage* /*image*/);
private:
void EnsureOwnership();
void ReleaseImage();
static bool Initialize();
static void Uninitialize();
SharedImage* m_sharedImage;
static NzImageLibrary::LibraryMap s_library;
static NzImageLoader::LoaderList s_loaders;
static NzImageManager::ManagerMap s_managerMap;
static NzImageManager::ManagerParams s_managerParameters;
};
}
#include <Nazara/Utility/Image.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzImageRef NzImage::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzImage> object(new NzImage(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
ImageRef Image::New(Args&&... args)
{
std::unique_ptr<Image> object(new Image(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -0,0 +1,20 @@
// 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
#include <memory>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
{
template<typename... Args>
ImageRef Image::New(Args&&... args)
{
std::unique_ptr<Image> object(new Image(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -12,68 +12,71 @@
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/Buffer.hpp>
class NzIndexBuffer;
using NzIndexBufferConstRef = NzObjectRef<const NzIndexBuffer>;
using NzIndexBufferRef = NzObjectRef<NzIndexBuffer>;
class NAZARA_UTILITY_API NzIndexBuffer : public NzRefCounted
namespace Nz
{
public:
NzIndexBuffer() = default;
NzIndexBuffer(bool largeIndices, NzBuffer* buffer);
NzIndexBuffer(bool largeIndices, NzBuffer* buffer, unsigned int startOffset, unsigned int endOffset);
NzIndexBuffer(bool largeIndices, unsigned int length, nzUInt32 storage = nzDataStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzIndexBuffer(const NzIndexBuffer& indexBuffer);
~NzIndexBuffer();
class IndexBuffer;
unsigned int ComputeCacheMissCount() const;
using IndexBufferConstRef = ObjectRef<const IndexBuffer>;
using IndexBufferRef = ObjectRef<IndexBuffer>;
bool Fill(const void* data, unsigned int startIndex, unsigned int length, bool forceDiscard = false);
bool FillRaw(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);
class NAZARA_UTILITY_API IndexBuffer : public RefCounted
{
public:
IndexBuffer() = default;
IndexBuffer(bool largeIndices, Buffer* buffer);
IndexBuffer(bool largeIndices, Buffer* buffer, unsigned int startOffset, unsigned int endOffset);
IndexBuffer(bool largeIndices, unsigned int length, UInt32 storage = DataStorage_Software, BufferUsage usage = BufferUsage_Static);
IndexBuffer(const IndexBuffer& indexBuffer);
~IndexBuffer();
NzBuffer* GetBuffer() const;
unsigned int GetEndOffset() const;
unsigned int GetIndexCount() const;
unsigned int GetStride() const;
unsigned int GetStartOffset() const;
unsigned int ComputeCacheMissCount() const;
bool HasLargeIndices() const;
bool Fill(const void* data, unsigned int startIndex, unsigned int length, bool forceDiscard = false);
bool FillRaw(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);
bool IsHardware() const;
bool IsValid() const;
Buffer* GetBuffer() const;
unsigned int GetEndOffset() const;
unsigned int GetIndexCount() const;
unsigned int GetStride() const;
unsigned int GetStartOffset() const;
void* Map(nzBufferAccess access, unsigned int startVertex = 0, unsigned int length = 0);
void* Map(nzBufferAccess access, unsigned int startVertex = 0, unsigned int length = 0) const;
void* MapRaw(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0);
void* MapRaw(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0) const;
bool HasLargeIndices() const;
void Optimize();
bool IsHardware() const;
bool IsValid() const;
void Reset();
void Reset(bool largeIndices, NzBuffer* buffer);
void Reset(bool largeIndices, NzBuffer* buffer, unsigned int startOffset, unsigned int endOffset);
void Reset(bool largeIndices, unsigned int length, nzUInt32 storage = nzDataStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
void Reset(const NzIndexBuffer& indexBuffer);
void* Map(BufferAccess access, unsigned int startVertex = 0, unsigned int length = 0);
void* Map(BufferAccess access, unsigned int startVertex = 0, unsigned int length = 0) const;
void* MapRaw(BufferAccess access, unsigned int offset = 0, unsigned int size = 0);
void* MapRaw(BufferAccess access, unsigned int offset = 0, unsigned int size = 0) const;
bool SetStorage(nzUInt32 storage);
void Optimize();
void Unmap() const;
void Reset();
void Reset(bool largeIndices, Buffer* buffer);
void Reset(bool largeIndices, Buffer* buffer, unsigned int startOffset, unsigned int endOffset);
void Reset(bool largeIndices, unsigned int length, UInt32 storage = DataStorage_Software, BufferUsage usage = BufferUsage_Static);
void Reset(const IndexBuffer& indexBuffer);
NzIndexBuffer& operator=(const NzIndexBuffer& indexBuffer);
bool SetStorage(UInt32 storage);
template<typename... Args> static NzIndexBufferRef New(Args&&... args);
void Unmap() const;
// Signals:
NazaraSignal(OnIndexBufferRelease, const NzIndexBuffer* /*indexBuffer*/);
IndexBuffer& operator=(const IndexBuffer& indexBuffer);
private:
NzBufferRef m_buffer;
bool m_largeIndices;
unsigned int m_endOffset;
unsigned int m_indexCount;
unsigned int m_startOffset;
};
template<typename... Args> static IndexBufferRef New(Args&&... args);
// Signals:
NazaraSignal(OnIndexBufferRelease, const IndexBuffer* /*indexBuffer*/);
private:
BufferRef m_buffer;
bool m_largeIndices;
unsigned int m_endOffset;
unsigned int m_indexCount;
unsigned int m_startOffset;
};
}
#include <Nazara/Utility/IndexBuffer.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzIndexBufferRef NzIndexBuffer::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzIndexBuffer> object(new NzIndexBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
IndexBufferRef IndexBuffer::New(Args&&... args)
{
std::unique_ptr<IndexBuffer> object(new IndexBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -9,70 +9,73 @@
#include <Nazara/Prerequesites.hpp>
class NzIndexMapper;
class NzIndexIterator
namespace Nz
{
friend NzIndexMapper;
class IndexMapper;
public:
class Reference;
class IndexIterator
{
friend IndexMapper;
NzIndexIterator();
NzIndexIterator(const NzIndexIterator& iterator);
~NzIndexIterator() = default;
public:
class Reference;
Reference operator*() const;
IndexIterator();
IndexIterator(const IndexIterator& iterator);
~IndexIterator() = default;
Reference operator[](unsigned int index) const;
Reference operator*() const;
NzIndexIterator& operator=(const NzIndexIterator& iterator);
Reference operator[](unsigned int index) const;
NzIndexIterator operator+(unsigned int indexCount) const;
NzIndexIterator operator-(unsigned int indexCount) const;
IndexIterator& operator=(const IndexIterator& iterator);
NzIndexIterator& operator+=(unsigned int indexCount);
NzIndexIterator& operator-=(unsigned int indexCount);
IndexIterator operator+(unsigned int indexCount) const;
IndexIterator operator-(unsigned int indexCount) const;
NzIndexIterator& operator++();
NzIndexIterator operator++(int);
IndexIterator& operator+=(unsigned int indexCount);
IndexIterator& operator-=(unsigned int indexCount);
NzIndexIterator& operator--();
NzIndexIterator operator--(int);
IndexIterator& operator++();
IndexIterator operator++(int);
friend bool operator==(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator!=(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator<(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator<=(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator>(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator>=(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
IndexIterator& operator--();
IndexIterator operator--(int);
private:
NzIndexIterator(NzIndexMapper* mapper, unsigned int index);
friend bool operator==(const IndexIterator& lhs, const IndexIterator& rhs);
friend bool operator!=(const IndexIterator& lhs, const IndexIterator& rhs);
friend bool operator<(const IndexIterator& lhs, const IndexIterator& rhs);
friend bool operator<=(const IndexIterator& lhs, const IndexIterator& rhs);
friend bool operator>(const IndexIterator& lhs, const IndexIterator& rhs);
friend bool operator>=(const IndexIterator& lhs, const IndexIterator& rhs);
NzIndexMapper* m_mapper;
unsigned int m_index;
};
private:
IndexIterator(IndexMapper* mapper, unsigned int index);
class NzIndexIterator::Reference
{
friend NzIndexIterator;
IndexMapper* m_mapper;
unsigned int m_index;
};
public:
Reference(const Reference& reference) = default;
~Reference() = default;
class IndexIterator::Reference
{
friend IndexIterator;
Reference& operator=(nzUInt32 value);
Reference& operator=(const Reference& reference);
public:
Reference(const Reference& reference) = default;
~Reference() = default;
operator nzUInt32() const;
Reference& operator=(UInt32 value);
Reference& operator=(const Reference& reference);
private:
Reference(NzIndexMapper* mapper, unsigned int index);
operator UInt32() const;
NzIndexMapper* m_mapper;
unsigned int m_index;
};
private:
Reference(IndexMapper* mapper, unsigned int index);
IndexMapper* m_mapper;
unsigned int m_index;
};
}
#include <Nazara/Utility/IndexIterator.inl>

View File

@@ -6,166 +6,169 @@
#include <iterator>
#include <Nazara/Utility/Debug.hpp>
inline NzIndexIterator::NzIndexIterator() :
m_mapper(nullptr),
m_index(0)
namespace Nz
{
}
inline IndexIterator::IndexIterator() :
m_mapper(nullptr),
m_index(0)
{
}
inline NzIndexIterator::NzIndexIterator(const NzIndexIterator& iterator) :
m_mapper(iterator.m_mapper),
m_index(iterator.m_index)
{
}
inline IndexIterator::IndexIterator(const IndexIterator& iterator) :
m_mapper(iterator.m_mapper),
m_index(iterator.m_index)
{
}
inline NzIndexIterator::NzIndexIterator(NzIndexMapper* mapper, unsigned int index) :
m_mapper(mapper),
m_index(index)
{
}
inline IndexIterator::IndexIterator(IndexMapper* mapper, unsigned int index) :
m_mapper(mapper),
m_index(index)
{
}
inline NzIndexIterator::Reference NzIndexIterator::operator*() const
{
return Reference(m_mapper, m_index);
}
inline IndexIterator::Reference IndexIterator::operator*() const
{
return Reference(m_mapper, m_index);
}
inline NzIndexIterator::Reference NzIndexIterator::operator[](unsigned int index) const
{
return Reference(m_mapper, m_index+index);
}
inline IndexIterator::Reference IndexIterator::operator[](unsigned int index) const
{
return Reference(m_mapper, m_index+index);
}
inline NzIndexIterator& NzIndexIterator::operator=(const NzIndexIterator& iterator)
{
m_mapper = iterator.m_mapper;
m_index = iterator.m_index;
inline IndexIterator& IndexIterator::operator=(const IndexIterator& iterator)
{
m_mapper = iterator.m_mapper;
m_index = iterator.m_index;
return *this;
}
return *this;
}
inline NzIndexIterator NzIndexIterator::operator+(unsigned int indexCount) const
{
return NzIndexIterator(m_mapper, m_index + indexCount);
}
inline IndexIterator IndexIterator::operator+(unsigned int indexCount) const
{
return IndexIterator(m_mapper, m_index + indexCount);
}
inline NzIndexIterator NzIndexIterator::operator-(unsigned int indexCount) const
{
return NzIndexIterator(m_mapper, m_index - indexCount);
}
inline IndexIterator IndexIterator::operator-(unsigned int indexCount) const
{
return IndexIterator(m_mapper, m_index - indexCount);
}
inline NzIndexIterator& NzIndexIterator::operator+=(unsigned int indexCount)
{
m_index += indexCount;
inline IndexIterator& IndexIterator::operator+=(unsigned int indexCount)
{
m_index += indexCount;
return *this;
}
return *this;
}
inline NzIndexIterator& NzIndexIterator::operator-=(unsigned int indexCount)
{
m_index += indexCount;
inline IndexIterator& IndexIterator::operator-=(unsigned int indexCount)
{
m_index += indexCount;
return *this;
}
return *this;
}
inline NzIndexIterator& NzIndexIterator::operator++()
{
m_index++;
inline IndexIterator& IndexIterator::operator++()
{
m_index++;
return *this;
}
return *this;
}
inline NzIndexIterator NzIndexIterator::operator++(int)
{
NzIndexIterator iterator(*this);
operator++();
inline IndexIterator IndexIterator::operator++(int)
{
IndexIterator iterator(*this);
operator++();
return iterator;
}
return iterator;
}
inline NzIndexIterator& NzIndexIterator::operator--()
{
m_index--;
inline IndexIterator& IndexIterator::operator--()
{
m_index--;
return *this;
}
return *this;
}
inline NzIndexIterator NzIndexIterator::operator--(int)
{
NzIndexIterator iterator(*this);
operator--();
inline IndexIterator IndexIterator::operator--(int)
{
IndexIterator iterator(*this);
operator--();
return iterator;
}
return iterator;
}
inline bool operator==(const NzIndexIterator& lhs, const NzIndexIterator& rhs)
{
return lhs.m_mapper == rhs.m_mapper && lhs.m_index == rhs.m_index;
}
inline bool operator==(const IndexIterator& lhs, const IndexIterator& rhs)
{
return lhs.m_mapper == rhs.m_mapper && lhs.m_index == rhs.m_index;
}
inline bool operator!=(const NzIndexIterator& lhs, const NzIndexIterator& rhs)
{
return !operator==(lhs, rhs);
}
inline bool operator!=(const IndexIterator& lhs, const IndexIterator& rhs)
{
return !operator==(lhs, rhs);
}
inline bool operator<(const NzIndexIterator& lhs, const NzIndexIterator& rhs)
{
if (lhs.m_mapper == rhs.m_mapper)
return lhs.m_index < rhs.m_index;
else
return lhs.m_mapper < rhs.m_mapper;
}
inline bool operator<(const IndexIterator& lhs, const IndexIterator& rhs)
{
if (lhs.m_mapper == rhs.m_mapper)
return lhs.m_index < rhs.m_index;
else
return lhs.m_mapper < rhs.m_mapper;
}
inline bool operator<=(const NzIndexIterator& lhs, const NzIndexIterator& rhs)
{
return !operator<(rhs, lhs);
}
inline bool operator<=(const IndexIterator& lhs, const IndexIterator& rhs)
{
return !operator<(rhs, lhs);
}
inline bool operator>(const NzIndexIterator& lhs, const NzIndexIterator& rhs)
{
return operator<(rhs, lhs);
}
inline bool operator>(const IndexIterator& lhs, const IndexIterator& rhs)
{
return operator<(rhs, lhs);
}
inline bool operator>=(const NzIndexIterator& lhs, const NzIndexIterator& rhs)
{
return !operator<(lhs, rhs);
}
inline bool operator>=(const IndexIterator& lhs, const IndexIterator& rhs)
{
return !operator<(lhs, rhs);
}
/**************************NzIndexIterator::Reference*************************/
/**************************IndexIterator::Reference*************************/
inline NzIndexIterator::Reference::Reference(NzIndexMapper* mapper, unsigned int index) :
m_mapper(mapper),
m_index(index)
{
}
inline IndexIterator::Reference::Reference(IndexMapper* mapper, unsigned int index) :
m_mapper(mapper),
m_index(index)
{
}
inline NzIndexIterator::Reference& NzIndexIterator::Reference::operator=(nzUInt32 value)
{
m_mapper->Set(m_index, value);
inline IndexIterator::Reference& IndexIterator::Reference::operator=(UInt32 value)
{
m_mapper->Set(m_index, value);
return *this;
}
return *this;
}
inline NzIndexIterator::Reference& NzIndexIterator::Reference::operator=(const NzIndexIterator::Reference& reference)
{
m_mapper->Set(m_index, reference); // Conversion implicite en UInt32
inline IndexIterator::Reference& IndexIterator::Reference::operator=(const IndexIterator::Reference& reference)
{
m_mapper->Set(m_index, reference); // Conversion implicite en UInt32
return *this;
}
return *this;
}
inline NzIndexIterator::Reference::operator nzUInt32() const
{
return m_mapper->Get(m_index);
inline IndexIterator::Reference::operator UInt32() const
{
return m_mapper->Get(m_index);
}
}
namespace std
{
template<>
struct iterator_traits<NzIndexIterator>
struct iterator_traits<Nz::IndexIterator>
{
using difference_type = ptrdiff_t;
using iterator_category = random_access_iterator_tag;
using reference = const NzIndexIterator::Reference&;
using pointer = const NzIndexIterator::Reference*;
using value_type = NzIndexIterator::Reference;
using reference = const Nz::IndexIterator::Reference&;
using pointer = const Nz::IndexIterator::Reference*;
using value_type = Nz::IndexIterator::Reference;
};
}

View File

@@ -11,41 +11,44 @@
#include <Nazara/Utility/BufferMapper.hpp>
#include <Nazara/Utility/IndexBuffer.hpp>
class NzIndexBuffer;
class NzIndexIterator;
class NzSubMesh;
using NzIndexMapperGetter = nzUInt32 (*)(const void* buffer, unsigned int i);
using NzIndexMapperSetter = void (*)(void* buffer, unsigned int i, nzUInt32 value);
class NAZARA_UTILITY_API NzIndexMapper
namespace Nz
{
public:
NzIndexMapper(NzIndexBuffer* indexBuffer, nzBufferAccess access = nzBufferAccess_ReadWrite);
NzIndexMapper(const NzIndexBuffer* indexBuffer, nzBufferAccess access = nzBufferAccess_ReadOnly);
NzIndexMapper(const NzSubMesh* subMesh);
~NzIndexMapper() = default;
class IndexBuffer;
class IndexIterator;
class SubMesh;
nzUInt32 Get(unsigned int i) const;
const NzIndexBuffer* GetBuffer() const;
unsigned int GetIndexCount() const;
using IndexMapperGetter = UInt32 (*)(const void* buffer, unsigned int i);
using IndexMapperSetter = void (*)(void* buffer, unsigned int i, UInt32 value);
void Set(unsigned int i, nzUInt32 value);
class NAZARA_UTILITY_API IndexMapper
{
public:
IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite);
IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly);
IndexMapper(const SubMesh* subMesh);
~IndexMapper() = default;
void Unmap();
UInt32 Get(unsigned int i) const;
const IndexBuffer* GetBuffer() const;
unsigned int GetIndexCount() const;
// Méthodes STD
NzIndexIterator begin();
//NzIndexConstIterator begin() const;
NzIndexIterator end();
//NzIndexIterator end() const;
// Méthodes STD
void Set(unsigned int i, UInt32 value);
private:
NzBufferMapper<NzIndexBuffer> m_mapper;
NzIndexMapperGetter m_getter;
NzIndexMapperSetter m_setter;
unsigned int m_indexCount;
void Unmap();
// Méthodes STD
IndexIterator begin();
//IndexConstIterator begin() const;
IndexIterator end();
//IndexIterator end() const;
// Méthodes STD
private:
BufferMapper<IndexBuffer> m_mapper;
IndexMapperGetter m_getter;
IndexMapperSetter m_setter;
unsigned int m_indexCount;
};
}
#endif // NAZARA_INDEXMAPPER_HPP

View File

@@ -12,35 +12,38 @@
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Utility/Node.hpp>
class NzSkeleton;
class NAZARA_UTILITY_API NzJoint : public NzNode
namespace Nz
{
public:
NzJoint(NzSkeleton* skeleton);
NzJoint(const NzJoint& joint);
~NzJoint() = default;
class Skeleton;
void EnsureSkinningMatrixUpdate() const;
class NAZARA_UTILITY_API Joint : public Node
{
public:
Joint(Skeleton* skeleton);
Joint(const Joint& joint);
~Joint() = default;
const NzMatrix4f& GetInverseBindMatrix() const;
NzString GetName() const;
NzSkeleton* GetSkeleton();
const NzSkeleton* GetSkeleton() const;
const NzMatrix4f& GetSkinningMatrix() const;
void EnsureSkinningMatrixUpdate() const;
void SetInverseBindMatrix(const NzMatrix4f& matrix);
void SetName(const NzString& name);
const Matrix4f& GetInverseBindMatrix() const;
String GetName() const;
Skeleton* GetSkeleton();
const Skeleton* GetSkeleton() const;
const Matrix4f& GetSkinningMatrix() const;
private:
void InvalidateNode();
void UpdateSkinningMatrix() const;
void SetInverseBindMatrix(const Matrix4f& matrix);
void SetName(const String& name);
NzMatrix4f m_inverseBindMatrix;
mutable NzMatrix4f m_skinningMatrix;
NzString m_name;
NzSkeleton* m_skeleton;
mutable bool m_skinningMatrixUpdated;
};
private:
void InvalidateNode();
void UpdateSkinningMatrix() const;
Matrix4f m_inverseBindMatrix;
mutable Matrix4f m_skinningMatrix;
String m_name;
Skeleton* m_skeleton;
mutable bool m_skinningMatrixUpdated;
};
}
#endif // NAZARA_JOINT_HPP

View File

@@ -10,15 +10,18 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
class NAZARA_UTILITY_API NzJoystick
namespace Nz
{
public:
NzJoystick() = delete;
~NzJoystick() = delete;
class NAZARA_UTILITY_API Joystick
{
public:
Joystick() = delete;
~Joystick() = delete;
static unsigned int GetMaxJoystickCount();
static unsigned int GetMaxJoystickCount();
static void Update();
};
static void Update();
};
}
#endif // NAZARA_JOYSTICK_HPP

View File

@@ -13,160 +13,163 @@
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Config.hpp>
class NAZARA_UTILITY_API NzKeyboard
namespace Nz
{
public:
enum Key
{
Undefined = -1,
class NAZARA_UTILITY_API Keyboard
{
public:
enum Key
{
Undefined = -1,
// Lettres
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
// Lettres
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
// Touches de fonction
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
// Touches de fonction
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
// Flèches directionnelles
Down,
Left,
Right,
Up,
// Flèches directionnelles
Down,
Left,
Right,
Up,
// Pavé numérique
Add,
Decimal,
Divide,
Multiply,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
Subtract,
// Pavé numérique
Add,
Decimal,
Divide,
Multiply,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
Subtract,
// Divers
Backslash,
Backspace,
Clear,
Comma,
Dash,
Delete,
End,
Equal,
Escape,
Home,
Insert,
LAlt,
LBracket,
LControl,
LShift,
LSystem,
Num0,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
PageDown,
PageUp,
Pause,
Period,
Print,
PrintScreen,
Quote,
RAlt,
RBracket,
RControl,
Return,
RShift,
RSystem,
Semicolon,
Slash,
Space,
Tab,
Tilde,
// Divers
Backslash,
Backspace,
Clear,
Comma,
Dash,
Delete,
End,
Equal,
Escape,
Home,
Insert,
LAlt,
LBracket,
LControl,
LShift,
LSystem,
Num0,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
PageDown,
PageUp,
Pause,
Period,
Print,
PrintScreen,
Quote,
RAlt,
RBracket,
RControl,
Return,
RShift,
RSystem,
Semicolon,
Slash,
Space,
Tab,
Tilde,
// Touches navigateur
Browser_Back,
Browser_Favorites,
Browser_Forward,
Browser_Home,
Browser_Refresh,
Browser_Search,
Browser_Stop,
// Touches navigateur
Browser_Back,
Browser_Favorites,
Browser_Forward,
Browser_Home,
Browser_Refresh,
Browser_Search,
Browser_Stop,
// Touches de contrôle de lecture
Media_Next,
Media_Play,
Media_Previous,
Media_Stop,
// Touches de contrôle de lecture
Media_Next,
Media_Play,
Media_Previous,
Media_Stop,
// Touches de contrôle du volume
Volume_Down,
Volume_Mute,
Volume_Up,
// Touches de contrôle du volume
Volume_Down,
Volume_Mute,
Volume_Up,
// Touches à verrouillage
CapsLock,
NumLock,
ScrollLock,
// Touches à verrouillage
CapsLock,
NumLock,
ScrollLock,
Count
};
Count
};
NzKeyboard() = delete;
~NzKeyboard() = delete;
Keyboard() = delete;
~Keyboard() = delete;
static NzString GetKeyName(Key key);
static bool IsKeyPressed(Key key);
};
static String GetKeyName(Key key);
static bool IsKeyPressed(Key key);
};
}
#endif // NAZARA_KEYBOARD_HPP

View File

@@ -22,127 +22,130 @@
#include <Nazara/Utility/SubMesh.hpp>
#include <Nazara/Utility/VertexStruct.hpp>
struct NAZARA_UTILITY_API NzMeshParams
namespace Nz
{
NzMeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
struct NAZARA_UTILITY_API MeshParams
{
MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
// La mise à l'échelle éventuelle que subira le mesh
NzVector3f scale = NzVector3f::Unit();
// La mise à l'échelle éventuelle que subira le mesh
Vector3f scale = Vector3f::Unit();
// Si ceci sera le stockage utilisé par les buffers
nzUInt32 storage = nzDataStorage_Hardware;
// Si ceci sera le stockage utilisé par les buffers
UInt32 storage = DataStorage_Hardware;
// Charger une version animée du mesh si possible ?
bool animated = true;
// Charger une version animée du mesh si possible ?
bool animated = true;
// Faut-il centrer le mesh autour de l'origine ?
bool center = false;
// Faut-il centrer le mesh autour de l'origine ?
bool center = false;
// Faut-il retourner les UV ?
bool flipUVs = false;
// Faut-il retourner les UV ?
bool flipUVs = false;
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
bool optimizeIndexBuffers = true;
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
bool optimizeIndexBuffers = true;
bool IsValid() const;
};
class NzMesh;
class NzPrimitiveList;
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex;
using NzMeshConstRef = NzObjectRef<const NzMesh>;
using NzMeshLibrary = NzObjectLibrary<NzMesh>;
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
using NzMeshManager = NzResourceManager<NzMesh, NzMeshParams>;
using NzMeshRef = NzObjectRef<NzMesh>;
struct NzMeshImpl;
class NAZARA_UTILITY_API NzMesh : public NzRefCounted, public NzResource
{
friend NzMeshLibrary;
friend NzMeshLoader;
friend NzMeshManager;
friend class NzUtility;
public:
NzMesh() = default;
~NzMesh();
void AddSubMesh(NzSubMesh* subMesh);
void AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
NzSubMesh* BuildSubMesh(const NzPrimitive& primitive, const NzMeshParams& params = NzMeshParams());
void BuildSubMeshes(const NzPrimitiveList& list, const NzMeshParams& params = NzMeshParams());
bool CreateSkeletal(unsigned int jointCount);
bool CreateStatic();
void Destroy();
void GenerateNormals();
void GenerateNormalsAndTangents();
void GenerateTangents();
const NzBoxf& GetAABB() const;
NzString GetAnimation() const;
nzAnimationType GetAnimationType() const;
unsigned int GetJointCount() const;
NzString GetMaterial(unsigned int index) const;
unsigned int GetMaterialCount() const;
NzSkeleton* GetSkeleton();
const NzSkeleton* GetSkeleton() const;
NzSubMesh* GetSubMesh(const NzString& identifier);
NzSubMesh* GetSubMesh(unsigned int index);
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
const NzSubMesh* GetSubMesh(unsigned int index) const;
unsigned int GetSubMeshCount() const;
int GetSubMeshIndex(const NzString& identifier) const;
unsigned int GetTriangleCount() const;
unsigned int GetVertexCount() const;
bool HasSubMesh(const NzString& identifier) const;
bool HasSubMesh(unsigned int index = 0) const;
void InvalidateAABB() const;
bool IsAnimable() const;
bool IsValid() const;
};
bool LoadFromFile(const NzString& filePath, const NzMeshParams& params = NzMeshParams());
bool LoadFromMemory(const void* data, std::size_t size, const NzMeshParams& params = NzMeshParams());
bool LoadFromStream(NzInputStream& stream, const NzMeshParams& params = NzMeshParams());
class Mesh;
class PrimitiveList;
void Recenter();
typedef VertexStruct_XYZ_Normal_UV_Tangent MeshVertex;
typedef VertexStruct_XYZ_Normal_UV_Tangent_Skinning SkeletalMeshVertex;
void RemoveSubMesh(const NzString& identifier);
void RemoveSubMesh(unsigned int index);
using MeshConstRef = ObjectRef<const Mesh>;
using MeshLibrary = ObjectLibrary<Mesh>;
using MeshLoader = ResourceLoader<Mesh, MeshParams>;
using MeshManager = ResourceManager<Mesh, MeshParams>;
using MeshRef = ObjectRef<Mesh>;
void SetAnimation(const NzString& animationPath);
void SetMaterial(unsigned int matIndex, const NzString& materialPath);
void SetMaterialCount(unsigned int matCount);
struct MeshImpl;
void Transform(const NzMatrix4f& matrix);
class NAZARA_UTILITY_API Mesh : public RefCounted, public Resource
{
friend MeshLibrary;
friend MeshLoader;
friend MeshManager;
friend class Utility;
template<typename... Args> static NzMeshRef New(Args&&... args);
public:
Mesh() = default;
~Mesh();
// Signals:
NazaraSignal(OnMeshDestroy, const NzMesh* /*mesh*/);
NazaraSignal(OnMeshRelease, const NzMesh* /*mesh*/);
void AddSubMesh(SubMesh* subMesh);
void AddSubMesh(const String& identifier, SubMesh* subMesh);
private:
NzMeshImpl* m_impl = nullptr;
SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams());
void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams());
static bool Initialize();
static void Uninitialize();
bool CreateSkeletal(unsigned int jointCount);
bool CreateStatic();
void Destroy();
static NzMeshLibrary::LibraryMap s_library;
static NzMeshLoader::LoaderList s_loaders;
static NzMeshManager::ManagerMap s_managerMap;
static NzMeshManager::ManagerParams s_managerParameters;
};
void GenerateNormals();
void GenerateNormalsAndTangents();
void GenerateTangents();
const Boxf& GetAABB() const;
String GetAnimation() const;
AnimationType GetAnimationType() const;
unsigned int GetJointCount() const;
String GetMaterial(unsigned int index) const;
unsigned int GetMaterialCount() const;
Skeleton* GetSkeleton();
const Skeleton* GetSkeleton() const;
SubMesh* GetSubMesh(const String& identifier);
SubMesh* GetSubMesh(unsigned int index);
const SubMesh* GetSubMesh(const String& identifier) const;
const SubMesh* GetSubMesh(unsigned int index) const;
unsigned int GetSubMeshCount() const;
int GetSubMeshIndex(const String& identifier) const;
unsigned int GetTriangleCount() const;
unsigned int GetVertexCount() const;
bool HasSubMesh(const String& identifier) const;
bool HasSubMesh(unsigned int index = 0) const;
void InvalidateAABB() const;
bool IsAnimable() const;
bool IsValid() const;
bool LoadFromFile(const String& filePath, const MeshParams& params = MeshParams());
bool LoadFromMemory(const void* data, std::size_t size, const MeshParams& params = MeshParams());
bool LoadFromStream(InputStream& stream, const MeshParams& params = MeshParams());
void Recenter();
void RemoveSubMesh(const String& identifier);
void RemoveSubMesh(unsigned int index);
void SetAnimation(const String& animationPath);
void SetMaterial(unsigned int matIndex, const String& materialPath);
void SetMaterialCount(unsigned int matCount);
void Transform(const Matrix4f& matrix);
template<typename... Args> static MeshRef New(Args&&... args);
// Signals:
NazaraSignal(OnMeshDestroy, const Mesh* /*mesh*/);
NazaraSignal(OnMeshRelease, const Mesh* /*mesh*/);
private:
MeshImpl* m_impl = nullptr;
static bool Initialize();
static void Uninitialize();
static MeshLibrary::LibraryMap s_library;
static MeshLoader::LoaderList s_loaders;
static MeshManager::ManagerMap s_managerMap;
static MeshManager::ManagerParams s_managerParameters;
};
}
#include <Nazara/Utility/Mesh.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzMeshRef NzMesh::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzMesh> object(new NzMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
MeshRef Mesh::New(Args&&... args)
{
std::unique_ptr<Mesh> object(new Mesh(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -9,14 +9,17 @@
#include <Nazara/Utility/Enums.hpp>
class NzIndexBuffer;
class NzVertexBuffer;
struct NzMeshData
namespace Nz
{
nzPrimitiveMode primitiveMode;
const NzIndexBuffer* indexBuffer;
const NzVertexBuffer* vertexBuffer;
};
class IndexBuffer;
class VertexBuffer;
struct MeshData
{
PrimitiveMode primitiveMode;
const IndexBuffer* indexBuffer;
const VertexBuffer* vertexBuffer;
};
}
#endif // NAZARA_MESHDATA_HPP

View File

@@ -13,32 +13,35 @@
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Utility/Config.hpp>
class NzWindow;
class NAZARA_UTILITY_API NzMouse
namespace Nz
{
public:
enum Button
{
Left,
Middle,
Right,
XButton1,
XButton2,
class Window;
Max = XButton2
};
class NAZARA_UTILITY_API Mouse
{
public:
enum Button
{
Left,
Middle,
Right,
XButton1,
XButton2,
NzMouse() = delete;
~NzMouse() = delete;
Max = XButton2
};
static NzVector2i GetPosition();
static NzVector2i GetPosition(const NzWindow& relativeTo);
static bool IsButtonPressed(Button button);
static void SetPosition(const NzVector2i& position);
static void SetPosition(const NzVector2i& position, const NzWindow& relativeTo, bool ignoreEvent = true);
static void SetPosition(int x, int y);
static void SetPosition(int x, int y, const NzWindow& relativeTo, bool ignoreEvent = true);
};
Mouse() = delete;
~Mouse() = delete;
static Vector2i GetPosition();
static Vector2i GetPosition(const Window& relativeTo);
static bool IsButtonPressed(Button button);
static void SetPosition(const Vector2i& position);
static void SetPosition(const Vector2i& position, const Window& relativeTo, bool ignoreEvent = true);
static void SetPosition(int x, int y);
static void SetPosition(int x, int y, const Window& relativeTo, bool ignoreEvent = true);
};
}
#endif // NAZARA_MOUSE_HPP

View File

@@ -17,110 +17,113 @@
#include <unordered_map>
#include <vector>
class NAZARA_UTILITY_API NzNode
namespace Nz
{
public:
NzNode();
NzNode(const NzNode& node);
virtual ~NzNode();
class NAZARA_UTILITY_API Node
{
public:
Node();
Node(const Node& node);
virtual ~Node();
void EnsureDerivedUpdate() const;
void EnsureTransformMatrixUpdate() const;
void EnsureDerivedUpdate() const;
void EnsureTransformMatrixUpdate() const;
virtual NzVector3f GetBackward() const;
const std::vector<NzNode*>& GetChilds() const;
virtual NzVector3f GetDown() const;
virtual NzVector3f GetForward() const;
bool GetInheritPosition() const;
bool GetInheritRotation() const;
bool GetInheritScale() const;
NzVector3f GetInitialPosition() const;
NzQuaternionf GetInitialRotation() const;
NzVector3f GetInitialScale() const;
virtual NzVector3f GetLeft() const;
virtual nzNodeType GetNodeType() const;
const NzNode* GetParent() const;
NzVector3f GetPosition(nzCoordSys coordSys = nzCoordSys_Global) const;
virtual NzVector3f GetRight() const;
NzQuaternionf GetRotation(nzCoordSys coordSys = nzCoordSys_Global) const;
NzVector3f GetScale(nzCoordSys coordSys = nzCoordSys_Global) const;
const NzMatrix4f& GetTransformMatrix() const;
virtual NzVector3f GetUp() const;
virtual Vector3f GetBackward() const;
const std::vector<Node*>& GetChilds() const;
virtual Vector3f GetDown() const;
virtual Vector3f GetForward() const;
bool GetInheritPosition() const;
bool GetInheritRotation() const;
bool GetInheritScale() const;
Vector3f GetInitialPosition() const;
Quaternionf GetInitialRotation() const;
Vector3f GetInitialScale() const;
virtual Vector3f GetLeft() const;
virtual nzNodeType GetNodeType() const;
const Node* GetParent() const;
Vector3f GetPosition(CoordSys coordSys = CoordSys_Global) const;
virtual Vector3f GetRight() const;
Quaternionf GetRotation(CoordSys coordSys = CoordSys_Global) const;
Vector3f GetScale(CoordSys coordSys = CoordSys_Global) const;
const Matrix4f& GetTransformMatrix() const;
virtual Vector3f GetUp() const;
bool HasChilds() const;
bool HasChilds() const;
NzNode& Interpolate(const NzNode& nodeA, const NzNode& nodeB, float interpolation, nzCoordSys coordSys = nzCoordSys_Global);
Node& Interpolate(const Node& nodeA, const Node& nodeB, float interpolation, CoordSys coordSys = CoordSys_Global);
NzNode& Move(const NzVector3f& movement, nzCoordSys coordSys = nzCoordSys_Local);
NzNode& Move(float movementX, float movementY, float movementZ = 0.f, nzCoordSys coordSys = nzCoordSys_Local);
Node& Move(const Vector3f& movement, CoordSys coordSys = CoordSys_Local);
Node& Move(float movementX, float movementY, float movementZ = 0.f, CoordSys coordSys = CoordSys_Local);
NzNode& Rotate(const NzQuaternionf& rotation, nzCoordSys coordSys = nzCoordSys_Local);
Node& Rotate(const Quaternionf& rotation, CoordSys coordSys = CoordSys_Local);
NzNode& Scale(const NzVector3f& scale);
NzNode& Scale(float scale);
NzNode& Scale(float scaleX, float scaleY, float scaleZ = 1.f);
Node& Scale(const Vector3f& scale);
Node& Scale(float scale);
Node& Scale(float scaleX, float scaleY, float scaleZ = 1.f);
void SetInheritRotation(bool inheritRotation);
void SetInheritScale(bool inheritScale);
void SetInheritPosition(bool inheritPosition);
void SetInitialRotation(const NzQuaternionf& quat);
void SetInitialScale(const NzVector3f& scale);
void SetInitialScale(float scale);
void SetInitialScale(float scaleX, float scaleY, float scaleZ = 1.f);
void SetInitialPosition(const NzVector3f& translation);
void SetInitialPosition(float translationX, float translationXY, float translationZ = 0.f);
void SetParent(const NzNode* node = nullptr, bool keepDerived = false);
void SetParent(const NzNode& node, bool keepDerived = false);
void SetPosition(const NzVector3f& translation, nzCoordSys coordSys = nzCoordSys_Local);
void SetPosition(float translationX, float translationY, float translationZ = 0.f, nzCoordSys coordSys = nzCoordSys_Local);
void SetRotation(const NzQuaternionf& quat, nzCoordSys coordSys = nzCoordSys_Local);
void SetScale(const NzVector3f& scale, nzCoordSys coordSys = nzCoordSys_Local);
void SetScale(float scale, nzCoordSys coordSys = nzCoordSys_Local);
void SetScale(float scaleX, float scaleY, float scaleZ = 1.f, nzCoordSys coordSys = nzCoordSys_Local);
void SetTransformMatrix(const NzMatrix4f& matrix);
void SetInheritRotation(bool inheritRotation);
void SetInheritScale(bool inheritScale);
void SetInheritPosition(bool inheritPosition);
void SetInitialRotation(const Quaternionf& quat);
void SetInitialScale(const Vector3f& scale);
void SetInitialScale(float scale);
void SetInitialScale(float scaleX, float scaleY, float scaleZ = 1.f);
void SetInitialPosition(const Vector3f& translation);
void SetInitialPosition(float translationX, float translationXY, float translationZ = 0.f);
void SetParent(const Node* node = nullptr, bool keepDerived = false);
void SetParent(const Node& node, bool keepDerived = false);
void SetPosition(const Vector3f& translation, CoordSys coordSys = CoordSys_Local);
void SetPosition(float translationX, float translationY, float translationZ = 0.f, CoordSys coordSys = CoordSys_Local);
void SetRotation(const Quaternionf& quat, CoordSys coordSys = CoordSys_Local);
void SetScale(const Vector3f& scale, CoordSys coordSys = CoordSys_Local);
void SetScale(float scale, CoordSys coordSys = CoordSys_Local);
void SetScale(float scaleX, float scaleY, float scaleZ = 1.f, CoordSys coordSys = CoordSys_Local);
void SetTransformMatrix(const Matrix4f& matrix);
// Local -> global
NzVector3f ToGlobalPosition(const NzVector3f& localPosition) const;
NzQuaternionf ToGlobalRotation(const NzQuaternionf& localRotation) const;
NzVector3f ToGlobalScale(const NzVector3f& localScale) const;
// Local -> global
Vector3f ToGlobalPosition(const Vector3f& localPosition) const;
Quaternionf ToGlobalRotation(const Quaternionf& localRotation) const;
Vector3f ToGlobalScale(const Vector3f& localScale) const;
// Global -> local
NzVector3f ToLocalPosition(const NzVector3f& globalPosition) const;
NzQuaternionf ToLocalRotation(const NzQuaternionf& globalRotation) const;
NzVector3f ToLocalScale(const NzVector3f& globalScale) const;
// Global -> local
Vector3f ToLocalPosition(const Vector3f& globalPosition) const;
Quaternionf ToLocalRotation(const Quaternionf& globalRotation) const;
Vector3f ToLocalScale(const Vector3f& globalScale) const;
NzNode& operator=(const NzNode& node);
Node& operator=(const Node& node);
// Signals:
NazaraSignal(OnNodeInvalidation, const NzNode* /*node*/);
NazaraSignal(OnNodeNewParent, const NzNode* /*node*/, const NzNode* /*parent*/);
NazaraSignal(OnNodeRelease, const NzNode* /*node*/);
// Signals:
NazaraSignal(OnNodeInvalidation, const Node* /*node*/);
NazaraSignal(OnNodeNewParent, const Node* /*node*/, const Node* /*parent*/);
NazaraSignal(OnNodeRelease, const Node* /*node*/);
protected:
void AddChild(NzNode* node) const;
virtual void InvalidateNode();
virtual void OnParenting(const NzNode* parent);
void RemoveChild(NzNode* node) const;
virtual void UpdateDerived() const;
virtual void UpdateTransformMatrix() const;
protected:
void AddChild(Node* node) const;
virtual void InvalidateNode();
virtual void OnParenting(const Node* parent);
void RemoveChild(Node* node) const;
virtual void UpdateDerived() const;
virtual void UpdateTransformMatrix() const;
mutable std::vector<NzNode*> m_childs;
mutable NzMatrix4f m_transformMatrix;
mutable NzQuaternionf m_derivedRotation;
NzQuaternionf m_initialRotation;
NzQuaternionf m_rotation;
mutable NzVector3f m_derivedPosition;
mutable NzVector3f m_derivedScale;
NzVector3f m_initialPosition;
NzVector3f m_initialScale;
NzVector3f m_position;
NzVector3f m_scale;
const NzNode* m_parent;
mutable bool m_derivedUpdated;
bool m_inheritPosition;
bool m_inheritRotation;
bool m_inheritScale;
mutable bool m_transformMatrixUpdated;
};
mutable std::vector<Node*> m_childs;
mutable Matrix4f m_transformMatrix;
mutable Quaternionf m_derivedRotation;
Quaternionf m_initialRotation;
Quaternionf m_rotation;
mutable Vector3f m_derivedPosition;
mutable Vector3f m_derivedScale;
Vector3f m_initialPosition;
Vector3f m_initialScale;
Vector3f m_position;
Vector3f m_scale;
const Node* m_parent;
mutable bool m_derivedUpdated;
bool m_inheritPosition;
bool m_inheritRotation;
bool m_inheritScale;
mutable bool m_transformMatrixUpdated;
};
}
#endif // NAZARA_NODE_HPP

View File

@@ -18,41 +18,44 @@
/// Ce serait plus lent que la conversion spécialisée (qui ne disparaîtra donc pas) mais ça permettrait au moteur de faire la conversion
/// entre n'importe quels formats non-compressés.
class NzPixelFormat
namespace Nz
{
friend class NzUtility;
class NzPixelFormat
{
friend class Utility;
public:
using ConvertFunction = std::function<nzUInt8*(const nzUInt8* start, const nzUInt8* end, nzUInt8* dst)>;
using FlipFunction = std::function<void(unsigned int width, unsigned int height, unsigned int depth, const nzUInt8* src, nzUInt8* dst)>;
public:
using ConvertFunction = std::function<UInt8*(const UInt8* start, const UInt8* end, UInt8* dst)>;
using FlipFunction = std::function<void(unsigned int width, unsigned int height, unsigned int depth, const UInt8* src, UInt8* dst)>;
static bool Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* src, void* dst);
static bool Convert(nzPixelFormat srcFormat, nzPixelFormat dstFormat, const void* start, const void* end, void* dst);
static bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst);
static bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst);
static bool Flip(nzPixelFlipping flipping, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
static bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
static nzUInt8 GetBitsPerPixel(nzPixelFormat format);
static nzUInt8 GetBytesPerPixel(nzPixelFormat format);
static nzPixelFormatType GetType(nzPixelFormat format);
static UInt8 GetBitsPerPixel(PixelFormatType format);
static UInt8 GetBytesPerPixel(PixelFormatType format);
static PixelFormatTypeType GetType(PixelFormatType format);
static bool HasAlpha(nzPixelFormat format);
static bool HasAlpha(PixelFormatType format);
static bool IsCompressed(nzPixelFormat format);
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
static bool IsValid(nzPixelFormat format);
static bool IsCompressed(PixelFormatType format);
static bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat);
static bool IsValid(PixelFormatType format);
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func);
static void SetFlipFunction(nzPixelFlipping flipping, nzPixelFormat format, FlipFunction func);
static void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func);
static void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func);
static NzString ToString(nzPixelFormat format);
static String ToString(PixelFormatType format);
private:
static bool Initialize();
static void Uninitialize();
private:
static bool Initialize();
static void Uninitialize();
static NAZARA_UTILITY_API ConvertFunction s_convertFunctions[nzPixelFormat_Max+1][nzPixelFormat_Max+1];
static NAZARA_UTILITY_API std::map<nzPixelFormat, FlipFunction> s_flipFunctions[nzPixelFlipping_Max+1];
};
static NAZARA_UTILITY_API ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1];
static NAZARA_UTILITY_API std::map<PixelFormatType, FlipFunction> s_flipFunctions[PixelFlipping_Max+1];
};
}
#include <Nazara/Utility/PixelFormat.inl>

File diff suppressed because it is too large Load Diff

View File

@@ -11,19 +11,22 @@
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
struct NzSequence
namespace Nz
{
NzString name;
unsigned int firstFrame;
unsigned int frameCount;
unsigned int frameRate;
};
struct Sequence
{
String name;
unsigned int firstFrame;
unsigned int frameCount;
unsigned int frameRate;
};
struct NzSequenceJoint
{
NzQuaternionf rotation;
NzVector3f position;
NzVector3f scale;
};
struct SequenceJoint
{
Quaternionf rotation;
Vector3f position;
Vector3f scale;
};
}
#endif // NAZARA_SEQUENCE_HPP

View File

@@ -14,58 +14,61 @@
#include <Nazara/Utility/Font.hpp>
#include <vector>
class NAZARA_UTILITY_API NzSimpleTextDrawer : public NzAbstractTextDrawer
namespace Nz
{
public:
NzSimpleTextDrawer();
NzSimpleTextDrawer(const NzSimpleTextDrawer& drawer);
NzSimpleTextDrawer(NzSimpleTextDrawer&& drawer);
virtual ~NzSimpleTextDrawer();
class NAZARA_UTILITY_API SimpleTextDrawer : public AbstractTextDrawer
{
public:
SimpleTextDrawer();
SimpleTextDrawer(const SimpleTextDrawer& drawer);
SimpleTextDrawer(SimpleTextDrawer&& drawer);
virtual ~SimpleTextDrawer();
const NzRectui& GetBounds() const;
unsigned int GetCharacterSize() const;
const NzColor& GetColor() const;
NzFont* GetFont() const;
NzFont* GetFont(unsigned int index) const override;
unsigned int GetFontCount() const override;
const Glyph& GetGlyph(unsigned int index) const override;
unsigned int GetGlyphCount() const override;
nzUInt32 GetStyle() const;
const NzString& GetText() const;
const Rectui& GetBounds() const;
unsigned int GetCharacterSize() const;
const Color& GetColor() const;
Font* GetFont() const;
Font* GetFont(unsigned int index) const override;
unsigned int GetFontCount() const override;
const Glyph& GetGlyph(unsigned int index) const override;
unsigned int GetGlyphCount() const override;
UInt32 GetStyle() const;
const String& GetText() const;
void SetCharacterSize(unsigned int characterSize);
void SetColor(const NzColor& color);
void SetFont(NzFont* font);
void SetStyle(nzUInt32 style);
void SetText(const NzString& str);
void SetCharacterSize(unsigned int characterSize);
void SetColor(const Color& color);
void SetFont(Font* font);
void SetStyle(UInt32 style);
void SetText(const String& str);
NzSimpleTextDrawer& operator=(const NzSimpleTextDrawer& drawer) = default;
NzSimpleTextDrawer& operator=(NzSimpleTextDrawer&& drawer);
SimpleTextDrawer& operator=(const SimpleTextDrawer& drawer) = default;
SimpleTextDrawer& operator=(SimpleTextDrawer&& drawer);
static NzSimpleTextDrawer Draw(const NzString& str, unsigned int characterSize, nzUInt32 style = nzTextStyle_Regular, const NzColor& color = NzColor::White);
static NzSimpleTextDrawer Draw(NzFont* font, const NzString& str, unsigned int characterSize, nzUInt32 style = nzTextStyle_Regular, const NzColor& color = NzColor::White);
static SimpleTextDrawer Draw(const String& str, unsigned int characterSize, UInt32 style = TextStyle_Regular, const Color& color = Color::White);
static SimpleTextDrawer Draw(Font* font, const String& str, unsigned int characterSize, UInt32 style = TextStyle_Regular, const Color& color = Color::White);
private:
void ConnectFontSlots();
void DisconnectFontSlots();
void OnFontAtlasLayerChanged(const NzFont* font, NzAbstractImage* oldLayer, NzAbstractImage* newLayer);
void OnFontInvalidated(const NzFont* font);
void OnFontRelease(const NzFont* object);
void UpdateGlyphs() const;
private:
void ConnectFontSlots();
void DisconnectFontSlots();
void OnFontAtlasLayerChanged(const Font* font, AbstractImage* oldLayer, AbstractImage* newLayer);
void OnFontInvalidated(const Font* font);
void OnFontRelease(const Font* object);
void UpdateGlyphs() const;
NazaraSlot(NzFont, OnFontAtlasChanged, m_atlasChangedSlot);
NazaraSlot(NzFont, OnFontAtlasLayerChanged, m_atlasLayerChangedSlot);
NazaraSlot(NzFont, OnFontGlyphCacheCleared, m_glyphCacheClearedSlot);
NazaraSlot(NzFont, OnFontRelease, m_fontReleaseSlot);
NazaraSlot(Font, OnFontAtlasChanged, m_atlasChangedSlot);
NazaraSlot(Font, OnFontAtlasLayerChanged, m_atlasLayerChangedSlot);
NazaraSlot(Font, OnFontGlyphCacheCleared, m_glyphCacheClearedSlot);
NazaraSlot(Font, OnFontRelease, m_fontReleaseSlot);
mutable std::vector<Glyph> m_glyphs;
NzColor m_color;
NzFontRef m_font;
mutable NzRectui m_bounds;
NzString m_text;
nzUInt32 m_style;
mutable bool m_glyphUpdated;
unsigned int m_characterSize;
};
mutable std::vector<Glyph> m_glyphs;
Color m_color;
FontRef m_font;
mutable Rectui m_bounds;
String m_text;
UInt32 m_style;
mutable bool m_glyphUpdated;
unsigned int m_characterSize;
};
}
#endif // NAZARA_SIMPLETEXTDRAWER_HPP

View File

@@ -12,44 +12,47 @@
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/SubMesh.hpp>
class NzSkeletalMesh;
using NzSkeletalMeshConstRef = NzObjectRef<const NzSkeletalMesh>;
using NzSkeletalMeshRef = NzObjectRef<NzSkeletalMesh>;
class NAZARA_UTILITY_API NzSkeletalMesh final : public NzSubMesh
namespace Nz
{
public:
NzSkeletalMesh(const NzMesh* parent);
~NzSkeletalMesh();
class SkeletalMesh;
bool Create(NzVertexBuffer* vertexBuffer);
void Destroy();
using SkeletalMeshConstRef = ObjectRef<const SkeletalMesh>;
using SkeletalMeshRef = ObjectRef<SkeletalMesh>;
const NzBoxf& GetAABB() const override;
nzAnimationType GetAnimationType() const final;
const NzIndexBuffer* GetIndexBuffer() const override;
NzVertexBuffer* GetVertexBuffer();
const NzVertexBuffer* GetVertexBuffer() const;
unsigned int GetVertexCount() const override;
class NAZARA_UTILITY_API SkeletalMesh final : public SubMesh
{
public:
SkeletalMesh(const Mesh* parent);
~SkeletalMesh();
bool IsAnimated() const final;
bool IsValid() const;
bool Create(VertexBuffer* vertexBuffer);
void Destroy();
void SetAABB(const NzBoxf& aabb);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
const Boxf& GetAABB() const override;
AnimationType GetAnimationType() const final;
const IndexBuffer* GetIndexBuffer() const override;
VertexBuffer* GetVertexBuffer();
const VertexBuffer* GetVertexBuffer() const;
unsigned int GetVertexCount() const override;
template<typename... Args> static NzSkeletalMeshRef New(Args&&... args);
bool IsAnimated() const final;
bool IsValid() const;
// Signals:
NazaraSignal(OnSkeletalMeshDestroy, const NzSkeletalMesh* /*skeletalMesh*/);
NazaraSignal(OnSkeletalMeshRelease, const NzSkeletalMesh* /*skeletalMesh*/);
void SetAABB(const Boxf& aabb);
void SetIndexBuffer(const IndexBuffer* indexBuffer);
private:
NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr;
NzVertexBufferRef m_vertexBuffer = nullptr;
};
template<typename... Args> static SkeletalMeshRef New(Args&&... args);
// Signals:
NazaraSignal(OnSkeletalMeshDestroy, const SkeletalMesh* /*skeletalMesh*/);
NazaraSignal(OnSkeletalMeshRelease, const SkeletalMesh* /*skeletalMesh*/);
private:
Boxf m_aabb;
IndexBufferConstRef m_indexBuffer = nullptr;
VertexBufferRef m_vertexBuffer = nullptr;
};
}
#include <Nazara/Utility/SkeletalMesh.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzSkeletalMeshRef NzSkeletalMesh::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzSkeletalMesh> object(new NzSkeletalMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
SkeletalMeshRef SkeletalMesh::New(Args&&... args)
{
std::unique_ptr<SkeletalMesh> object(new SkeletalMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -16,64 +16,67 @@
#include <Nazara/Utility/Joint.hpp>
#include <vector>
class NzSkeleton;
using NzSkeletonConstRef = NzObjectRef<const NzSkeleton>;
using NzSkeletonLibrary = NzObjectLibrary<NzSkeleton>;
using NzSkeletonRef = NzObjectRef<NzSkeleton>;
struct NzSkeletonImpl;
class NAZARA_UTILITY_API NzSkeleton : public NzRefCounted
namespace Nz
{
friend NzJoint;
friend NzSkeletonLibrary;
friend class NzUtility;
class Skeleton;
public:
NzSkeleton() = default;
NzSkeleton(const NzSkeleton& skeleton);
~NzSkeleton();
using SkeletonConstRef = ObjectRef<const Skeleton>;
using SkeletonLibrary = ObjectLibrary<Skeleton>;
using SkeletonRef = ObjectRef<Skeleton>;
bool Create(unsigned int jointCount);
void Destroy();
struct SkeletonImpl;
const NzBoxf& GetAABB() const;
NzJoint* GetJoint(const NzString& jointName);
NzJoint* GetJoint(unsigned int index);
const NzJoint* GetJoint(const NzString& jointName) const;
const NzJoint* GetJoint(unsigned int index) const;
NzJoint* GetJoints();
const NzJoint* GetJoints() const;
unsigned int GetJointCount() const;
int GetJointIndex(const NzString& jointName) const;
class NAZARA_UTILITY_API Skeleton : public RefCounted
{
friend Joint;
friend SkeletonLibrary;
friend class Utility;
void Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation);
void Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount);
public:
Skeleton() = default;
Skeleton(const Skeleton& skeleton);
~Skeleton();
bool IsValid() const;
bool Create(unsigned int jointCount);
void Destroy();
NzSkeleton& operator=(const NzSkeleton& skeleton);
const Boxf& GetAABB() const;
Joint* GetJoint(const String& jointName);
Joint* GetJoint(unsigned int index);
const Joint* GetJoint(const String& jointName) const;
const Joint* GetJoint(unsigned int index) const;
Joint* GetJoints();
const Joint* GetJoints() const;
unsigned int GetJointCount() const;
int GetJointIndex(const String& jointName) const;
template<typename... Args> static NzSkeletonRef New(Args&&... args);
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation);
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount);
// Signals:
NazaraSignal(OnSkeletonDestroy, const NzSkeleton* /*skeleton*/);
NazaraSignal(OnSkeletonJointsInvalidated, const NzSkeleton* /*skeleton*/);
NazaraSignal(OnSkeletonRelease, const NzSkeleton* /*skeleton*/);
bool IsValid() const;
private:
void InvalidateJoints();
void InvalidateJointMap();
void UpdateJointMap() const;
Skeleton& operator=(const Skeleton& skeleton);
static bool Initialize();
static void Uninitialize();
template<typename... Args> static SkeletonRef New(Args&&... args);
NzSkeletonImpl* m_impl = nullptr;
// Signals:
NazaraSignal(OnSkeletonDestroy, const Skeleton* /*skeleton*/);
NazaraSignal(OnSkeletonJointsInvalidated, const Skeleton* /*skeleton*/);
NazaraSignal(OnSkeletonRelease, const Skeleton* /*skeleton*/);
static NzSkeletonLibrary::LibraryMap s_library;
};
private:
void InvalidateJoints();
void InvalidateJointMap();
void UpdateJointMap() const;
static bool Initialize();
static void Uninitialize();
SkeletonImpl* m_impl = nullptr;
static SkeletonLibrary::LibraryMap s_library;
};
}
#include <Nazara/Utility/Skeleton.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzSkeletonRef NzSkeleton::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzSkeleton> object(new NzSkeleton(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
SkeletonRef Skeleton::New(Args&&... args)
{
std::unique_ptr<Skeleton> object(new Skeleton(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -11,48 +11,51 @@
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/SubMesh.hpp>
class NzStaticMesh;
using NzStaticMeshConstRef = NzObjectRef<const NzStaticMesh>;
using NzStaticMeshRef = NzObjectRef<NzStaticMesh>;
class NAZARA_UTILITY_API NzStaticMesh final : public NzSubMesh
namespace Nz
{
public:
NzStaticMesh(const NzMesh* parent);
~NzStaticMesh();
class StaticMesh;
void Center();
using StaticMeshConstRef = ObjectRef<const StaticMesh>;
using StaticMeshRef = ObjectRef<StaticMesh>;
bool Create(NzVertexBuffer* vertexBuffer);
void Destroy();
class NAZARA_UTILITY_API StaticMesh final : public SubMesh
{
public:
StaticMesh(const Mesh* parent);
~StaticMesh();
bool GenerateAABB();
void Center();
const NzBoxf& GetAABB() const override;
nzAnimationType GetAnimationType() const final;
const NzIndexBuffer* GetIndexBuffer() const override;
NzVertexBuffer* GetVertexBuffer();
const NzVertexBuffer* GetVertexBuffer() const;
unsigned int GetVertexCount() const override;
bool Create(VertexBuffer* vertexBuffer);
void Destroy();
bool IsAnimated() const final;
bool IsValid() const;
bool GenerateAABB();
void SetAABB(const NzBoxf& aabb);
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
const Boxf& GetAABB() const override;
AnimationType GetAnimationType() const final;
const IndexBuffer* GetIndexBuffer() const override;
VertexBuffer* GetVertexBuffer();
const VertexBuffer* GetVertexBuffer() const;
unsigned int GetVertexCount() const override;
template<typename... Args> static NzStaticMeshRef New(Args&&... args);
bool IsAnimated() const final;
bool IsValid() const;
// Signals:
NazaraSignal(OnStaticMeshDestroy, const NzStaticMesh* /*staticMesh*/);
NazaraSignal(OnStaticMeshRelease, const NzStaticMesh* /*staticMesh*/);
void SetAABB(const Boxf& aabb);
void SetIndexBuffer(const IndexBuffer* indexBuffer);
private:
NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr;
NzVertexBufferRef m_vertexBuffer = nullptr;
};
template<typename... Args> static StaticMeshRef New(Args&&... args);
// Signals:
NazaraSignal(OnStaticMeshDestroy, const StaticMesh* /*staticMesh*/);
NazaraSignal(OnStaticMeshRelease, const StaticMesh* /*staticMesh*/);
private:
Boxf m_aabb;
IndexBufferConstRef m_indexBuffer = nullptr;
VertexBufferRef m_vertexBuffer = nullptr;
};
}
#include <Nazara/Utility/StaticMesh.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzStaticMeshRef NzStaticMesh::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzStaticMesh> object(new NzStaticMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
StaticMeshRef StaticMesh::New(Args&&... args)
{
std::unique_ptr<StaticMesh> object(new StaticMesh(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -16,45 +16,48 @@
#include <Nazara/Utility/VertexBuffer.hpp>
#include <Nazara/Utility/VertexDeclaration.hpp>
class NzMesh;
class NzSubMesh;
using NzSubMeshConstRef = NzObjectRef<const NzSubMesh>;
using NzSubMeshRef = NzObjectRef<NzSubMesh>;
class NAZARA_UTILITY_API NzSubMesh : public NzRefCounted
namespace Nz
{
friend NzMesh;
class Mesh;
class SubMesh;
public:
NzSubMesh(const NzMesh* parent);
virtual ~NzSubMesh();
using SubMeshConstRef = ObjectRef<const SubMesh>;
using SubMeshRef = ObjectRef<SubMesh>;
void GenerateNormals();
void GenerateNormalsAndTangents();
void GenerateTangents();
class NAZARA_UTILITY_API SubMesh : public RefCounted
{
friend Mesh;
virtual const NzBoxf& GetAABB() const = 0;
virtual nzAnimationType GetAnimationType() const = 0;
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
unsigned int GetMaterialIndex() const;
const NzMesh* GetParent() const;
nzPrimitiveMode GetPrimitiveMode() const;
unsigned int GetTriangleCount() const;
virtual unsigned int GetVertexCount() const = 0;
public:
SubMesh(const Mesh* parent);
virtual ~SubMesh();
virtual bool IsAnimated() const = 0;
void GenerateNormals();
void GenerateNormalsAndTangents();
void GenerateTangents();
void SetMaterialIndex(unsigned int matIndex);
void SetPrimitiveMode(nzPrimitiveMode mode);
virtual const Boxf& GetAABB() const = 0;
virtual AnimationType GetAnimationType() const = 0;
virtual const IndexBuffer* GetIndexBuffer() const = 0;
unsigned int GetMaterialIndex() const;
const Mesh* GetParent() const;
PrimitiveMode GetPrimitiveMode() const;
unsigned int GetTriangleCount() const;
virtual unsigned int GetVertexCount() const = 0;
// Signals:
NazaraSignal(OnSubMeshRelease, const NzSubMesh* /*subMesh*/);
virtual bool IsAnimated() const = 0;
protected:
nzPrimitiveMode m_primitiveMode;
const NzMesh* m_parent;
unsigned int m_matIndex;
};
void SetMaterialIndex(unsigned int matIndex);
void SetPrimitiveMode(PrimitiveMode mode);
// Signals:
NazaraSignal(OnSubMeshRelease, const SubMesh* /*subMesh*/);
protected:
PrimitiveMode m_primitiveMode;
const Mesh* m_parent;
unsigned int m_matIndex;
};
}
#endif // NAZARA_SUBMESH_HPP

View File

@@ -11,27 +11,30 @@
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/IndexMapper.hpp>
class NzSubMesh;
class NAZARA_UTILITY_API NzTriangleIterator
namespace Nz
{
public:
NzTriangleIterator(nzPrimitiveMode primitiveMode, const NzIndexBuffer* indexBuffer);
NzTriangleIterator(NzSubMesh* subMesh);
~NzTriangleIterator() = default;
class SubMesh;
bool Advance();
class NAZARA_UTILITY_API TriangleIterator
{
public:
TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer* indexBuffer);
TriangleIterator(SubMesh* subMesh);
~TriangleIterator() = default;
nzUInt32 operator[](unsigned int i) const;
bool Advance();
void Unmap();
UInt32 operator[](unsigned int i) const;
private:
nzPrimitiveMode m_primitiveMode;
nzUInt32 m_triangleIndices[3];
NzIndexMapper m_indexMapper;
unsigned int m_currentIndex;
unsigned int m_indexCount;
};
void Unmap();
private:
PrimitiveMode m_primitiveMode;
UInt32 m_triangleIndices[3];
IndexMapper m_indexMapper;
unsigned int m_currentIndex;
unsigned int m_indexCount;
};
}
#endif // NAZARA_TRIANGLEITERATOR_HPP

View File

@@ -12,23 +12,26 @@
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
class NAZARA_UTILITY_API NzUtility
namespace Nz
{
public:
NzUtility() = delete;
~NzUtility() = delete;
class NAZARA_UTILITY_API Utility
{
public:
Utility() = delete;
~Utility() = delete;
static bool Initialize();
static bool Initialize();
static bool IsInitialized();
static bool IsInitialized();
static void Uninitialize();
static void Uninitialize();
static unsigned int ComponentCount[nzComponentType_Max+1];
static std::size_t ComponentStride[nzComponentType_Max+1];
static unsigned int ComponentCount[ComponentType_Max+1];
static std::size_t ComponentStride[ComponentType_Max+1];
private:
static unsigned int s_moduleReferenceCounter;
};
private:
static unsigned int s_moduleReferenceCounter;
};
}
#endif // NAZARA_UTILITY_HPP

View File

@@ -14,64 +14,67 @@
#include <Nazara/Utility/Buffer.hpp>
#include <Nazara/Utility/VertexDeclaration.hpp>
class NzVertexBuffer;
using NzVertexBufferConstRef = NzObjectRef<NzVertexBuffer>;
using NzVertexBufferRef = NzObjectRef<NzVertexBuffer>;
class NAZARA_UTILITY_API NzVertexBuffer : public NzRefCounted
namespace Nz
{
public:
NzVertexBuffer() = default;
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, NzBuffer* buffer);
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, NzBuffer* buffer, unsigned int startOffset, unsigned int endOffset);
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzUInt32 storage = nzDataStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
~NzVertexBuffer();
class VertexBuffer;
bool Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard = false);
bool FillRaw(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);
using VertexBufferConstRef = ObjectRef<VertexBuffer>;
using VertexBufferRef = ObjectRef<VertexBuffer>;
NzBuffer* GetBuffer() const;
unsigned int GetEndOffset() const;
unsigned int GetStartOffset() const;
unsigned int GetStride() const;
unsigned int GetVertexCount() const;
const NzVertexDeclaration* GetVertexDeclaration() const;
class NAZARA_UTILITY_API VertexBuffer : public RefCounted
{
public:
VertexBuffer() = default;
VertexBuffer(const VertexDeclaration* vertexDeclaration, Buffer* buffer);
VertexBuffer(const VertexDeclaration* vertexDeclaration, Buffer* buffer, unsigned int startOffset, unsigned int endOffset);
VertexBuffer(const VertexDeclaration* vertexDeclaration, unsigned int length, UInt32 storage = DataStorage_Software, BufferUsage usage = BufferUsage_Static);
VertexBuffer(const VertexBuffer& vertexBuffer);
~VertexBuffer();
bool IsHardware() const;
bool IsValid() const;
bool Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard = false);
bool FillRaw(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);
void* Map(nzBufferAccess access, unsigned int startVertex = 0, unsigned int length = 0);
void* Map(nzBufferAccess access, unsigned int startVertex = 0, unsigned int length = 0) const;
void* MapRaw(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0);
void* MapRaw(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0) const;
Buffer* GetBuffer() const;
unsigned int GetEndOffset() const;
unsigned int GetStartOffset() const;
unsigned int GetStride() const;
unsigned int GetVertexCount() const;
const VertexDeclaration* GetVertexDeclaration() const;
void Reset();
void Reset(const NzVertexDeclaration* vertexDeclaration, NzBuffer* buffer);
void Reset(const NzVertexDeclaration* vertexDeclaration, NzBuffer* buffer, unsigned int startOffset, unsigned int endOffset);
void Reset(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzUInt32 storage = nzDataStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
void Reset(const NzVertexBuffer& vertexBuffer);
bool IsHardware() const;
bool IsValid() const;
bool SetStorage(nzUInt32 storage);
void SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration);
void* Map(BufferAccess access, unsigned int startVertex = 0, unsigned int length = 0);
void* Map(BufferAccess access, unsigned int startVertex = 0, unsigned int length = 0) const;
void* MapRaw(BufferAccess access, unsigned int offset = 0, unsigned int size = 0);
void* MapRaw(BufferAccess access, unsigned int offset = 0, unsigned int size = 0) const;
void Unmap() const;
void Reset();
void Reset(const VertexDeclaration* vertexDeclaration, Buffer* buffer);
void Reset(const VertexDeclaration* vertexDeclaration, Buffer* buffer, unsigned int startOffset, unsigned int endOffset);
void Reset(const VertexDeclaration* vertexDeclaration, unsigned int length, UInt32 storage = DataStorage_Software, BufferUsage usage = BufferUsage_Static);
void Reset(const VertexBuffer& vertexBuffer);
NzVertexBuffer& operator=(const NzVertexBuffer& vertexBuffer);
bool SetStorage(UInt32 storage);
void SetVertexDeclaration(const VertexDeclaration* vertexDeclaration);
template<typename... Args> static NzVertexBufferRef New(Args&&... args);
void Unmap() const;
// Signals:
NazaraSignal(OnVertexBufferRelease, const NzVertexBuffer* /*vertexBuffer*/);
VertexBuffer& operator=(const VertexBuffer& vertexBuffer);
private:
NzBufferRef m_buffer;
NzVertexDeclarationConstRef m_vertexDeclaration;
unsigned int m_endOffset;
unsigned int m_startOffset;
unsigned int m_vertexCount;
};
template<typename... Args> static VertexBufferRef New(Args&&... args);
// Signals:
NazaraSignal(OnVertexBufferRelease, const VertexBuffer* /*vertexBuffer*/);
private:
BufferRef m_buffer;
VertexDeclarationConstRef m_vertexDeclaration;
unsigned int m_endOffset;
unsigned int m_startOffset;
unsigned int m_vertexCount;
};
}
#include <Nazara/Utility/VertexBuffer.inl>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzVertexBufferRef NzVertexBuffer::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzVertexBuffer> object(new NzVertexBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
VertexBufferRef VertexBuffer::New(Args&&... args)
{
std::unique_ptr<VertexBuffer> object(new VertexBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -15,64 +15,67 @@
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
class NzVertexDeclaration;
using NzVertexDeclarationConstRef = NzObjectRef<const NzVertexDeclaration>;
using NzVertexDeclarationLibrary = NzObjectLibrary<NzVertexDeclaration>;
using NzVertexDeclarationRef = NzObjectRef<NzVertexDeclaration>;
class NAZARA_UTILITY_API NzVertexDeclaration : public NzRefCounted
namespace Nz
{
friend NzVertexDeclarationLibrary;
friend class NzUtility;
class VertexDeclaration;
public:
NzVertexDeclaration();
NzVertexDeclaration(const NzVertexDeclaration& declaration);
~NzVertexDeclaration();
using VertexDeclarationConstRef = ObjectRef<const VertexDeclaration>;
using VertexDeclarationLibrary = ObjectLibrary<VertexDeclaration>;
using VertexDeclarationRef = ObjectRef<VertexDeclaration>;
void DisableComponent(nzVertexComponent component);
void EnableComponent(nzVertexComponent component, nzComponentType type, unsigned int offset);
class NAZARA_UTILITY_API VertexDeclaration : public RefCounted
{
friend VertexDeclarationLibrary;
friend class Utility;
void GetComponent(nzVertexComponent component, bool* enabled, nzComponentType* type, unsigned int* offset) const;
unsigned int GetStride() const;
public:
VertexDeclaration();
VertexDeclaration(const VertexDeclaration& declaration);
~VertexDeclaration();
void SetStride(unsigned int stride);
void DisableComponent(VertexComponent component);
void EnableComponent(VertexComponent component, ComponentType type, unsigned int offset);
NzVertexDeclaration& operator=(const NzVertexDeclaration& declaration);
void GetComponent(VertexComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const;
unsigned int GetStride() const;
static NzVertexDeclaration* Get(nzVertexLayout layout);
static bool IsTypeSupported(nzComponentType type);
template<typename... Args> static NzVertexDeclarationRef New(Args&&... args);
void SetStride(unsigned int stride);
// Signals:
NazaraSignal(OnVertexDeclarationRelease, const NzVertexDeclaration* /*vertexDeclaration*/);
VertexDeclaration& operator=(const VertexDeclaration& declaration);
private:
static bool Initialize();
static void Uninitialize();
static VertexDeclaration* Get(VertexLayout layout);
static bool IsTypeSupported(ComponentType type);
template<typename... Args> static VertexDeclarationRef New(Args&&... args);
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
// Signals:
NazaraSignal(OnVertexDeclarationRelease, const VertexDeclaration* /*vertexDeclaration*/);
/*
** -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)
*/
};
private:
static bool Initialize();
static void Uninitialize();
Component m_components[nzVertexComponent_Max+1];
unsigned int m_stride;
struct Component
{
ComponentType 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
static NzVertexDeclaration s_declarations[nzVertexLayout_Max+1];
static NzVertexDeclarationLibrary::LibraryMap s_library;
};
/*
** -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];
unsigned int m_stride;
static VertexDeclaration s_declarations[VertexLayout_Max+1];
static VertexDeclarationLibrary::LibraryMap s_library;
};
}
#include <Nazara/Utility/VertexDeclaration.hpp>

View File

@@ -5,13 +5,16 @@
#include <memory>
#include <Nazara/Utility/Debug.hpp>
template<typename... Args>
NzVertexDeclarationRef NzVertexDeclaration::New(Args&&... args)
namespace Nz
{
std::unique_ptr<NzVertexDeclaration> object(new NzVertexDeclaration(std::forward<Args>(args)...));
object->SetPersistent(false);
template<typename... Args>
VertexDeclarationRef VertexDeclaration::New(Args&&... args)
{
std::unique_ptr<VertexDeclaration> object(new VertexDeclaration(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -13,22 +13,25 @@
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/VertexBuffer.hpp>
class NzSubMesh;
class NAZARA_UTILITY_API NzVertexMapper
namespace Nz
{
public:
NzVertexMapper(NzSubMesh* subMesh, nzBufferAccess access = nzBufferAccess_ReadWrite);
NzVertexMapper(NzVertexBuffer* vertexBuffer, nzBufferAccess access = nzBufferAccess_ReadWrite);
~NzVertexMapper();
class SubMesh;
template<typename T> NzSparsePtr<T> GetComponentPtr(nzVertexComponent component);
class NAZARA_UTILITY_API VertexMapper
{
public:
VertexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite);
VertexMapper(VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadWrite);
~VertexMapper();
void Unmap();
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component);
private:
NzBufferMapper<NzVertexBuffer> m_mapper;
};
void Unmap();
private:
BufferMapper<VertexBuffer> m_mapper;
};
}
#include <Nazara/Utility/VertexMapper.inl>

View File

@@ -5,28 +5,31 @@
#include <Nazara/Utility/VertexDeclaration.hpp>
#include <Nazara/Utility/Debug.hpp>
template <typename T>
NzSparsePtr<T> NzVertexMapper::GetComponentPtr(nzVertexComponent component)
namespace Nz
{
// On récupère la déclaration depuis le buffer
const NzVertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration();
// Ensuite le composant qui nous intéresse
bool enabled;
nzComponentType type;
unsigned int offset;
declaration->GetComponent(component, &enabled, &type, &offset);
if (enabled)
template <typename T>
SparsePtr<T> VertexMapper::GetComponentPtr(VertexComponent component)
{
///TODO: Vérifier le rapport entre le type de l'attribut et le type template ?
return NzSparsePtr<T>(static_cast<nzUInt8*>(m_mapper.GetPointer()) + offset, declaration->GetStride());
}
else
{
NazaraError("Attribute 0x" + NzString::Number(component, 16) + " is not enabled");
return NzSparsePtr<T>();
// On récupère la déclaration depuis le buffer
const VertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration();
// Ensuite le composant qui nous intéresse
bool enabled;
ComponentType type;
unsigned int offset;
declaration->GetComponent(component, &enabled, &type, &offset);
if (enabled)
{
///TODO: Vérifier le rapport entre le type de l'attribut et le type template ?
return SparsePtr<T>(static_cast<UInt8*>(m_mapper.GetPointer()) + offset, declaration->GetStride());
}
else
{
NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled");
return SparsePtr<T>();
}
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -11,73 +11,76 @@
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Math/Vector3.hpp>
/******************************* Structures 2D *******************************/
struct NzVertexStruct_XY
namespace Nz
{
NzVector2f position;
};
/******************************* Structures 2D *******************************/
struct NzVertexStruct_XY_Color : NzVertexStruct_XY
{
NzColor color;
};
struct VertexStruct_XY
{
Vector2f position;
};
struct NzVertexStruct_XY_UV : NzVertexStruct_XY
{
NzVector2f uv;
};
struct VertexStruct_XY_Color : VertexStruct_XY
{
Color color;
};
struct NzVertexStruct_XY_Color_UV : NzVertexStruct_XY_Color
{
NzVector2f uv;
};
struct VertexStruct_XY_UV : VertexStruct_XY
{
Vector2f uv;
};
/******************************* Structures 3D *******************************/
struct VertexStruct_XY_Color_UV : VertexStruct_XY_Color
{
Vector2f uv;
};
struct NzVertexStruct_XYZ
{
NzVector3f position;
};
/******************************* Structures 3D *******************************/
struct NzVertexStruct_XYZ_Color : NzVertexStruct_XYZ
{
NzColor color;
};
struct VertexStruct_XYZ
{
Vector3f position;
};
struct NzVertexStruct_XYZ_Color_UV : NzVertexStruct_XYZ_Color
{
NzVector2f uv;
};
struct VertexStruct_XYZ_Color : VertexStruct_XYZ
{
Color color;
};
struct NzVertexStruct_XYZ_Normal : NzVertexStruct_XYZ
{
NzVector3f normal;
};
struct VertexStruct_XYZ_Color_UV : VertexStruct_XYZ_Color
{
Vector2f uv;
};
struct NzVertexStruct_XYZ_Normal_UV : NzVertexStruct_XYZ_Normal
{
NzVector2f uv;
};
struct VertexStruct_XYZ_Normal : VertexStruct_XYZ
{
Vector3f normal;
};
struct NzVertexStruct_XYZ_Normal_UV_Tangent : NzVertexStruct_XYZ_Normal_UV
{
NzVector3f tangent;
};
struct VertexStruct_XYZ_Normal_UV : VertexStruct_XYZ_Normal
{
Vector2f uv;
};
struct NzVertexStruct_XYZ_UV : NzVertexStruct_XYZ
{
NzVector2f uv;
};
struct VertexStruct_XYZ_Normal_UV_Tangent : VertexStruct_XYZ_Normal_UV
{
Vector3f tangent;
};
/************************* Structures 3D (+ Skinning) ************************/
struct VertexStruct_XYZ_UV : VertexStruct_XYZ
{
Vector2f uv;
};
struct NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning : NzVertexStruct_XYZ_Normal_UV_Tangent
{
nzInt32 weightCount;
/************************* Structures 3D (+ Skinning) ************************/
NzVector4f weights;
NzVector4i32 jointIndexes;
};
struct VertexStruct_XYZ_Normal_UV_Tangent_Skinning : VertexStruct_XYZ_Normal_UV_Tangent
{
Int32 weightCount;
Vector4f weights;
Vector4i32 jointIndexes;
};
}
#endif // NAZARA_VERTEXSTRUCT_HPP

View File

@@ -13,27 +13,30 @@
#include <Nazara/Utility/Config.hpp>
#include <vector>
class NAZARA_UTILITY_API NzVideoMode
namespace Nz
{
public:
NzVideoMode();
NzVideoMode(unsigned int w, unsigned int h, nzUInt8 bpp);
class NAZARA_UTILITY_API VideoMode
{
public:
VideoMode();
VideoMode(unsigned int w, unsigned int h, UInt8 bpp);
bool IsFullscreenValid() const;
bool IsFullscreenValid() const;
nzUInt8 bitsPerPixel;
unsigned int height;
unsigned int width;
UInt8 bitsPerPixel;
unsigned int height;
unsigned int width;
static NzVideoMode GetDesktopMode();
static const std::vector<NzVideoMode>& GetFullscreenModes();
};
static VideoMode GetDesktopMode();
static const std::vector<VideoMode>& GetFullscreenModes();
};
bool operator==(const NzVideoMode& left, const NzVideoMode& right);
bool operator!=(const NzVideoMode& left, const NzVideoMode& right);
bool operator<(const NzVideoMode& left, const NzVideoMode& right);
bool operator<=(const NzVideoMode& left, const NzVideoMode& right);
bool operator>(const NzVideoMode& left, const NzVideoMode& right);
bool operator>=(const NzVideoMode& left, const NzVideoMode& right);
bool operator==(const VideoMode& left, const VideoMode& right);
bool operator!=(const VideoMode& left, const VideoMode& right);
bool operator<(const VideoMode& left, const VideoMode& right);
bool operator<=(const VideoMode& left, const VideoMode& right);
bool operator>(const VideoMode& left, const VideoMode& right);
bool operator>=(const VideoMode& left, const VideoMode& right);
}
#endif // NAZARA_VIDEOMODE_HPP

View File

@@ -24,99 +24,102 @@
#include <Nazara/Core/Mutex.hpp>
#endif
class NzCursor;
class NzImage;
class NzIcon;
class NzWindowImpl;
class NAZARA_UTILITY_API NzWindow
namespace Nz
{
friend NzWindowImpl;
friend class NzMouse;
friend class NzUtility;
class Cursor;
class Image;
class Icon;
class WindowImpl;
public:
NzWindow();
NzWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
NzWindow(NzWindowHandle handle);
NzWindow(const NzWindow&) = delete;
NzWindow(NzWindow&&) = delete; ///TODO
virtual ~NzWindow();
class NAZARA_UTILITY_API Window
{
friend WindowImpl;
friend class Mouse;
friend class Utility;
void Close();
public:
Window();
Window(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
Window(WindowHandle handle);
Window(const Window&) = delete;
Window(Window&&) = delete; ///TODO
virtual ~Window();
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default);
bool Create(NzWindowHandle handle);
void Close();
void Destroy();
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
bool Create(WindowHandle handle);
void EnableKeyRepeat(bool enable);
void EnableSmoothScrolling(bool enable);
void Destroy();
NzWindowHandle GetHandle() const;
unsigned int GetHeight() const;
NzVector2i GetPosition() const;
NzVector2ui GetSize() const;
nzUInt32 GetStyle() const;
NzString GetTitle() const;
unsigned int GetWidth() const;
void EnableKeyRepeat(bool enable);
void EnableSmoothScrolling(bool enable);
bool HasFocus() const;
WindowHandle GetHandle() const;
unsigned int GetHeight() const;
Vector2i GetPosition() const;
Vector2ui GetSize() const;
UInt32 GetStyle() const;
String GetTitle() const;
unsigned int GetWidth() const;
bool IsMinimized() const;
bool IsOpen(bool checkClosed = true);
bool IsOpen() const;
bool IsValid() const;
bool IsVisible() const;
bool HasFocus() const;
bool PollEvent(NzEvent* event);
bool IsMinimized() const;
bool IsOpen(bool checkClosed = true);
bool IsOpen() const;
bool IsValid() const;
bool IsVisible() const;
void SetCursor(nzWindowCursor cursor);
void SetCursor(const NzCursor& cursor);
void SetEventListener(bool listener);
void SetFocus();
void SetIcon(const NzIcon& icon);
void SetMaximumSize(const NzVector2i& maxSize);
void SetMaximumSize(int width, int height);
void SetMinimumSize(const NzVector2i& minSize);
void SetMinimumSize(int width, int height);
void SetPosition(const NzVector2i& position);
void SetPosition(int x, int y);
void SetSize(const NzVector2i& size);
void SetSize(unsigned int width, unsigned int height);
void SetStayOnTop(bool stayOnTop);
void SetTitle(const NzString& title);
void SetVisible(bool visible);
bool PollEvent(WindowEvent* event);
bool WaitEvent(NzEvent* event);
void SetCursor(WindowCursor cursor);
void SetCursor(const Cursor& cursor);
void SetEventListener(bool listener);
void SetFocus();
void SetIcon(const Icon& icon);
void SetMaximumSize(const Vector2i& maxSize);
void SetMaximumSize(int width, int height);
void SetMinimumSize(const Vector2i& minSize);
void SetMinimumSize(int width, int height);
void SetPosition(const Vector2i& position);
void SetPosition(int x, int y);
void SetSize(const Vector2i& size);
void SetSize(unsigned int width, unsigned int height);
void SetStayOnTop(bool stayOnTop);
void SetTitle(const String& title);
void SetVisible(bool visible);
NzWindow& operator=(const NzWindow&) = delete;
NzWindow& operator=(NzWindow&&) = delete; ///TODO
bool WaitEvent(WindowEvent* event);
protected:
virtual bool OnWindowCreated();
virtual void OnWindowDestroy();
virtual void OnWindowResized();
Window& operator=(const Window&) = delete;
Window& operator=(Window&&) = delete; ///TODO
NzWindowImpl* m_impl;
protected:
virtual bool OnWindowCreated();
virtual void OnWindowDestroy();
virtual void OnWindowResized();
private:
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
void PushEvent(const NzEvent& event);
WindowImpl* m_impl;
static bool Initialize();
static void Uninitialize();
private:
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
void PushEvent(const WindowEvent& event);
std::queue<NzEvent> m_events;
#if NAZARA_UTILITY_THREADED_WINDOW
NzConditionVariable m_eventCondition;
NzMutex m_eventMutex;
NzMutex m_eventConditionMutex;
bool m_eventListener;
bool m_waitForEvent;
#endif
bool m_closed;
bool m_ownsWindow;
};
static bool Initialize();
static void Uninitialize();
std::queue<WindowEvent> m_events;
#if NAZARA_UTILITY_THREADED_WINDOW
ConditionVariable m_eventCondition;
Mutex m_eventMutex;
Mutex m_eventConditionMutex;
bool m_eventListener;
bool m_waitForEvent;
#endif
bool m_closed;
bool m_ownsWindow;
};
}
#endif // NAZARA_WINDOW_HPP

View File

@@ -9,15 +9,18 @@
#include <Nazara/Prerequesites.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS)
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
typedef void* NzWindowHandle;
#elif defined(NAZARA_PLATFORM_LINUX)
#include <xcb/xcb.h>
// http://en.wikipedia.org/wiki/Xlib#Data_types
using NzWindowHandle = xcb_window_t;
#else
#error Lack of implementation: WindowHandle
#endif
namespace Nz
{
#if defined(NAZARA_PLATFORM_WINDOWS)
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
typedef void* WindowHandle;
#elif defined(NAZARA_PLATFORM_LINUX)
#include <xcb/xcb.h>
// http://en.wikipedia.org/wiki/Xlib#Data_types
using WindowHandle = xcb_window_t;
#else
#error Lack of implementation: WindowHandle
#endif
}
#endif // NAZARA_WINDOWHANDLE_HPP