Merge branch 'master' into NDK-ShadowMapping
Former-commit-id: 83435ab51753299b30a102871fbcd5558d2ac4f1
This commit is contained in:
commit
9cf5e4b68c
|
|
@ -5,6 +5,9 @@ lib/*
|
|||
# Feature page
|
||||
build/scripts/features/index.html
|
||||
|
||||
# Documentation
|
||||
doc
|
||||
|
||||
# Codeblocks
|
||||
build/**/*.cbp
|
||||
build/**/*.cbp
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
if (not _OPTIONS["united"]) then
|
||||
project "NazaraModuleName"
|
||||
end
|
||||
|
||||
files
|
||||
{
|
||||
"../include/Nazara/ModuleName/**.hpp",
|
||||
"../include/Nazara/ModuleName/**.inl",
|
||||
"../src/Nazara/ModuleName/**.hpp",
|
||||
"../src/Nazara/ModuleName/**.cpp"
|
||||
}
|
||||
|
||||
if (os.is("windows")) then
|
||||
excludes { "../src/Nazara/ModuleName/Posix/*.hpp", "../src/Nazara/ModuleName/Posix/*.cpp" }
|
||||
else
|
||||
excludes { "../src/Nazara/ModuleName/Win32/*.hpp", "../src/Nazara/ModuleName/Win32/*.cpp" }
|
||||
end
|
||||
|
||||
if (_OPTIONS["united"]) then
|
||||
excludes "../src/Nazara/ModuleName/Debug/NewOverload.cpp"
|
||||
else
|
||||
configuration "DebugStatic"
|
||||
links "NazaraCore-s-d"
|
||||
|
||||
configuration "ReleaseStatic"
|
||||
links "NazaraCore-s"
|
||||
|
||||
configuration "DebugDLL"
|
||||
links "NazaraCore-d"
|
||||
|
||||
configuration "ReleaseDLL"
|
||||
links "NazaraCore"
|
||||
end
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
MODULE.Name = "ModuleName"
|
||||
|
||||
MODULE.Libraries = {
|
||||
"NazaraCore"
|
||||
}
|
||||
|
||||
MODULE.OsFiles.Windows = {
|
||||
"../src/Nazara/ModuleName/Win32/**.hpp",
|
||||
"../src/Nazara/ModuleName/Win32/**.cpp"
|
||||
}
|
||||
|
||||
MODULE.OsFiles.Posix = {
|
||||
"../src/Nazara/ModuleName/Posix/**.hpp",
|
||||
"../src/Nazara/ModuleName/Posix/**.cpp"
|
||||
}
|
||||
|
|
@ -7,12 +7,14 @@
|
|||
#ifndef NAZARA_CLASSNAME_HPP
|
||||
#define NAZARA_CLASSNAME_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/ModuleName/Config.hpp>
|
||||
|
||||
class NAZARA_API NzClassName
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_MODULENAME_API ClassName
|
||||
{
|
||||
public:
|
||||
NzClassName();
|
||||
ClassName();
|
||||
|
||||
int GetAttribute() const;
|
||||
|
||||
|
|
@ -20,6 +22,7 @@ class NAZARA_API NzClassName
|
|||
|
||||
private:
|
||||
int m_attribute;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_CLASSNAME_HPP
|
||||
|
|
|
|||
|
|
@ -40,4 +40,14 @@
|
|||
/// Vérification des valeurs et types de certaines constantes
|
||||
#include <Nazara/ModuleName/ConfigCheck.hpp>
|
||||
|
||||
#if !defined(NAZARA_STATIC)
|
||||
#ifdef NAZARA_MODULENAME_BUILD
|
||||
#define NAZARA_MODULENAME_API NAZARA_EXPORT
|
||||
#else
|
||||
#define NAZARA_MODULENAME_API NAZARA_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define NAZARA_MODULENAME_API
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_MODULENAME_MANAGE_MEMORY
|
||||
#undef NAZARA_MODULENAME_MANAGE_MEMORY
|
||||
#define NAZARA_MODULENAME_MANAGE_MEMORY 1
|
||||
#define NAZARA_MODULENAME_MANAGE_MEMORY 0
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_CHECK_MODULENAME_HPP
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (C) 2014 AUTHORS
|
||||
// Copyright (C) YEAR AUTHORS
|
||||
// This file is part of the "Nazara Engine - Module name"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||
#if NAZARA_MODULENAME_HPP
|
||||
#if NAZARA_MODULENAME_MANAGE_MEMORY
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/ModuleName/Config.hpp>
|
||||
|
||||
class NAZARA_API NzModuleName
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_MODULENAME_API ModuleName
|
||||
{
|
||||
public:
|
||||
NzModuleName() = delete;
|
||||
~NzModuleName() = delete;
|
||||
ModuleName() = delete;
|
||||
~ModuleName() = delete;
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
|
|
@ -24,6 +27,7 @@ class NAZARA_API NzModuleName
|
|||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MODULENAME_HPP
|
||||
|
|
|
|||
|
|
@ -5,17 +5,21 @@
|
|||
#include <Nazara/ModuleName/ClassName.hpp>
|
||||
#include <Nazara/ModuleName/Debug.hpp>
|
||||
|
||||
NzClassName::NzClassName() :
|
||||
m_attribute(42)
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
ClassName::ClassName() :
|
||||
m_attribute(42)
|
||||
{
|
||||
}
|
||||
|
||||
int NzClassName::GetAttribute() const
|
||||
{
|
||||
int ClassName::GetAttribute() const
|
||||
{
|
||||
return m_attribute;
|
||||
}
|
||||
|
||||
void ClassName::SetAttribute(int attribute)
|
||||
{
|
||||
m_attribute = attribute;
|
||||
}
|
||||
}
|
||||
|
||||
void NzClassName::SetAttribute(int attribute)
|
||||
{
|
||||
m_attribute = attribute;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,22 +10,22 @@
|
|||
|
||||
void* operator new(std::size_t size)
|
||||
{
|
||||
return NzMemoryManager::Allocate(size, false);
|
||||
return Nz::MemoryManager::Allocate(size, false);
|
||||
}
|
||||
|
||||
void* operator new[](std::size_t size)
|
||||
{
|
||||
return NzMemoryManager::Allocate(size, true);
|
||||
return Nz::MemoryManager::Allocate(size, true);
|
||||
}
|
||||
|
||||
void operator delete(void* pointer) noexcept
|
||||
{
|
||||
NzMemoryManager::Free(pointer, false);
|
||||
Nz::MemoryManager::Free(pointer, false);
|
||||
}
|
||||
|
||||
void operator delete[](void* pointer) noexcept
|
||||
{
|
||||
NzMemoryManager::Free(pointer, true);
|
||||
Nz::MemoryManager::Free(pointer, true);
|
||||
}
|
||||
|
||||
#endif // NAZARA_MODULENAME_MANAGE_MEMORY
|
||||
|
|
|
|||
|
|
@ -10,16 +10,18 @@
|
|||
#include <Nazara/ModuleName/Config.hpp>
|
||||
#include <Nazara/ModuleName/Debug.hpp>
|
||||
|
||||
bool NzModuleName::Initialize()
|
||||
namespace Nz
|
||||
{
|
||||
bool ModuleName::Initialize()
|
||||
{
|
||||
if (s_moduleReferenceCounter > 0)
|
||||
{
|
||||
s_moduleReferenceCounter++;
|
||||
return true; // Déjà initialisé
|
||||
return true; // Already initialized
|
||||
}
|
||||
|
||||
// Initialisation des dépendances
|
||||
if (!NzCore::Initialize())
|
||||
// Initialize module dependencies
|
||||
if (!Core::Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize core module");
|
||||
return false;
|
||||
|
|
@ -27,38 +29,42 @@ bool NzModuleName::Initialize()
|
|||
|
||||
s_moduleReferenceCounter++;
|
||||
|
||||
// Initialisation du module
|
||||
NzCallOnExit onExit(NzModuleName::Uninitialize);
|
||||
CallOnExit onExit(ModuleName::Uninitialize);
|
||||
|
||||
// Initialize module here
|
||||
|
||||
onExit.Reset();
|
||||
|
||||
NazaraNotice("Initialized: ModuleName module");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool NzModuleName::IsInitialized()
|
||||
{
|
||||
bool ModuleName::IsInitialized()
|
||||
{
|
||||
return s_moduleReferenceCounter != 0;
|
||||
}
|
||||
}
|
||||
|
||||
void NzModuleName::Uninitialize()
|
||||
{
|
||||
void ModuleName::Uninitialize()
|
||||
{
|
||||
if (s_moduleReferenceCounter != 1)
|
||||
{
|
||||
// Le module est soit encore utilisé, soit pas initialisé
|
||||
// Either the module is not initialized, either it was initialized multiple times
|
||||
if (s_moduleReferenceCounter > 1)
|
||||
s_moduleReferenceCounter--;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Libération du module
|
||||
s_moduleReferenceCounter = 0;
|
||||
|
||||
// Uninitialize module here
|
||||
|
||||
NazaraNotice("Uninitialized: ModuleName module");
|
||||
|
||||
// Libération des dépendances
|
||||
NzCore::Uninitialize();
|
||||
// Free module dependencies
|
||||
Core::Uninitialize();
|
||||
}
|
||||
|
||||
unsigned int ModuleName::s_moduleReferenceCounter = 0;
|
||||
}
|
||||
|
||||
unsigned int NzModuleName::s_moduleReferenceCounter = 0;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Ndk
|
|||
{
|
||||
inline Application::Application()
|
||||
{
|
||||
NzErrorFlags errFlags(nzErrorFlag_ThrowException, true);
|
||||
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
|
||||
|
||||
// Initialisation du SDK
|
||||
Sdk::Initialize();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Ndk
|
|||
|
||||
BaseComponent(ComponentIndex componentIndex);
|
||||
BaseComponent(const BaseComponent&) = default;
|
||||
BaseComponent(BaseComponent&&) noexcept = default;
|
||||
BaseComponent(BaseComponent&&) = default;
|
||||
virtual ~BaseComponent();
|
||||
|
||||
virtual BaseComponent* Clone() const = 0;
|
||||
|
|
@ -32,7 +32,7 @@ namespace Ndk
|
|||
ComponentIndex GetIndex() const;
|
||||
|
||||
BaseComponent& operator=(const BaseComponent&) = default;
|
||||
BaseComponent& operator=(BaseComponent&&) noexcept = default;
|
||||
BaseComponent& operator=(BaseComponent&&) = default;
|
||||
|
||||
protected:
|
||||
ComponentIndex m_componentIndex;
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ namespace Ndk
|
|||
static inline void Uninitialize();
|
||||
|
||||
std::vector<EntityHandle> m_entities;
|
||||
NzBitset<nzUInt64> m_entityBits;
|
||||
NzBitset<> m_excludedComponents;
|
||||
mutable NzBitset<> m_filterResult;
|
||||
NzBitset<> m_requiredAnyComponents;
|
||||
NzBitset<> m_requiredComponents;
|
||||
Nz::Bitset<Nz::UInt64> m_entityBits;
|
||||
Nz::Bitset<> m_excludedComponents;
|
||||
mutable Nz::Bitset<> m_filterResult;
|
||||
Nz::Bitset<> m_requiredAnyComponents;
|
||||
Nz::Bitset<> m_requiredComponents;
|
||||
SystemIndex m_systemIndex;
|
||||
World* m_world;
|
||||
float m_updateCounter;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Ndk
|
|||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API CameraComponent : public Component<CameraComponent>, public NzAbstractViewer
|
||||
class NDK_API CameraComponent : public Component<CameraComponent>, public Nz::AbstractViewer
|
||||
{
|
||||
public:
|
||||
inline CameraComponent();
|
||||
|
|
@ -34,26 +34,26 @@ namespace Ndk
|
|||
inline void EnsureViewportUpdate() const;
|
||||
|
||||
inline float GetAspectRatio() const;
|
||||
inline NzVector3f GetEyePosition() const;
|
||||
inline NzVector3f GetForward() const;
|
||||
inline Nz::Vector3f GetEyePosition() const;
|
||||
inline Nz::Vector3f GetForward() const;
|
||||
inline float GetFOV() const;
|
||||
inline const NzFrustumf& GetFrustum() const;
|
||||
inline const Nz::Frustumf& GetFrustum() const;
|
||||
inline unsigned int GetLayer() const;
|
||||
inline const NzMatrix4f& GetProjectionMatrix() const;
|
||||
inline nzProjectionType GetProjectionType() const;
|
||||
inline const NzRenderTarget* GetTarget() const;
|
||||
inline const NzRectf& GetTargetRegion() const;
|
||||
inline const NzMatrix4f& GetViewMatrix() const;
|
||||
inline const NzRecti& GetViewport() const;
|
||||
inline const Nz::Matrix4f& GetProjectionMatrix() const;
|
||||
inline Nz::ProjectionType GetProjectionType() const;
|
||||
inline const Nz::RenderTarget* GetTarget() const;
|
||||
inline const Nz::Rectf& GetTargetRegion() const;
|
||||
inline const Nz::Matrix4f& GetViewMatrix() const;
|
||||
inline const Nz::Recti& GetViewport() const;
|
||||
inline float GetZFar() const;
|
||||
inline float GetZNear() const;
|
||||
|
||||
inline void SetFOV(float fov);
|
||||
inline void SetLayer(unsigned int layer);
|
||||
inline void SetProjectionType(nzProjectionType projection);
|
||||
inline void SetTarget(const NzRenderTarget* renderTarget);
|
||||
inline void SetTargetRegion(const NzRectf& region);
|
||||
inline void SetViewport(const NzRecti& viewport);
|
||||
inline void SetProjectionType(Nz::ProjectionType projection);
|
||||
inline void SetTarget(const Nz::RenderTarget* renderTarget);
|
||||
inline void SetTargetRegion(const Nz::Rectf& region);
|
||||
inline void SetViewport(const Nz::Recti& viewport);
|
||||
inline void SetZFar(float zFar);
|
||||
inline void SetZNear(float zNear);
|
||||
|
||||
|
|
@ -69,26 +69,26 @@ namespace Ndk
|
|||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
void OnNodeInvalidated(const NzNode* node);
|
||||
void OnRenderTargetRelease(const NzRenderTarget* renderTarget);
|
||||
void OnRenderTargetSizeChange(const NzRenderTarget* renderTarget);
|
||||
void OnNodeInvalidated(const Nz::Node* node);
|
||||
void OnRenderTargetRelease(const Nz::RenderTarget* renderTarget);
|
||||
void OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget);
|
||||
|
||||
void UpdateFrustum() const;
|
||||
void UpdateProjectionMatrix() const;
|
||||
void UpdateViewMatrix() const;
|
||||
void UpdateViewport() const;
|
||||
|
||||
NazaraSlot(NzNode, OnNodeInvalidation, m_nodeInvalidationSlot);
|
||||
NazaraSlot(NzRenderTarget, OnRenderTargetRelease, m_targetReleaseSlot);
|
||||
NazaraSlot(NzRenderTarget, OnRenderTargetSizeChange, m_targetResizeSlot);
|
||||
NazaraSlot(Nz::Node, OnNodeInvalidation, m_nodeInvalidationSlot);
|
||||
NazaraSlot(Nz::RenderTarget, OnRenderTargetRelease, m_targetReleaseSlot);
|
||||
NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, m_targetResizeSlot);
|
||||
|
||||
nzProjectionType m_projectionType;
|
||||
mutable NzFrustumf m_frustum;
|
||||
mutable NzMatrix4f m_projectionMatrix;
|
||||
mutable NzMatrix4f m_viewMatrix;
|
||||
NzRectf m_targetRegion;
|
||||
mutable NzRecti m_viewport;
|
||||
const NzRenderTarget* m_target;
|
||||
Nz::ProjectionType m_projectionType;
|
||||
mutable Nz::Frustumf m_frustum;
|
||||
mutable Nz::Matrix4f m_projectionMatrix;
|
||||
mutable Nz::Matrix4f m_viewMatrix;
|
||||
Nz::Rectf m_targetRegion;
|
||||
mutable Nz::Recti m_viewport;
|
||||
const Nz::RenderTarget* m_target;
|
||||
mutable bool m_frustumUpdated;
|
||||
mutable bool m_projectionMatrixUpdated;
|
||||
mutable bool m_viewMatrixUpdated;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
namespace Ndk
|
||||
{
|
||||
inline CameraComponent::CameraComponent() :
|
||||
m_projectionType(nzProjectionType_Perspective),
|
||||
m_projectionType(Nz::ProjectionType_Perspective),
|
||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
||||
m_target(nullptr),
|
||||
m_frustumUpdated(false),
|
||||
|
|
@ -25,7 +25,7 @@ namespace Ndk
|
|||
|
||||
inline CameraComponent::CameraComponent(const CameraComponent& camera) :
|
||||
Component(camera),
|
||||
NzAbstractViewer(camera),
|
||||
AbstractViewer(camera),
|
||||
m_projectionType(camera.m_projectionType),
|
||||
m_targetRegion(camera.m_targetRegion),
|
||||
m_target(nullptr),
|
||||
|
|
@ -78,7 +78,7 @@ namespace Ndk
|
|||
return m_fov;
|
||||
}
|
||||
|
||||
inline const NzFrustumf& CameraComponent::GetFrustum() const
|
||||
inline const Nz::Frustumf& CameraComponent::GetFrustum() const
|
||||
{
|
||||
EnsureFrustumUpdate();
|
||||
|
||||
|
|
@ -90,36 +90,36 @@ namespace Ndk
|
|||
return m_layer;
|
||||
}
|
||||
|
||||
inline const NzMatrix4f& CameraComponent::GetProjectionMatrix() const
|
||||
inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const
|
||||
{
|
||||
EnsureProjectionMatrixUpdate();
|
||||
|
||||
return m_projectionMatrix;
|
||||
}
|
||||
|
||||
inline nzProjectionType CameraComponent::GetProjectionType() const
|
||||
inline Nz::ProjectionType CameraComponent::GetProjectionType() const
|
||||
{
|
||||
return m_projectionType;
|
||||
}
|
||||
|
||||
inline const NzRenderTarget* CameraComponent::GetTarget() const
|
||||
inline const Nz::RenderTarget* CameraComponent::GetTarget() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
inline const NzRectf& CameraComponent::GetTargetRegion() const
|
||||
inline const Nz::Rectf& CameraComponent::GetTargetRegion() const
|
||||
{
|
||||
return m_targetRegion;
|
||||
}
|
||||
|
||||
inline const NzMatrix4f& CameraComponent::GetViewMatrix() const
|
||||
inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const
|
||||
{
|
||||
EnsureViewMatrixUpdate();
|
||||
|
||||
return m_viewMatrix;
|
||||
}
|
||||
|
||||
inline const NzRecti& CameraComponent::GetViewport() const
|
||||
inline const Nz::Recti& CameraComponent::GetViewport() const
|
||||
{
|
||||
EnsureViewportUpdate();
|
||||
|
||||
|
|
@ -138,36 +138,42 @@ namespace Ndk
|
|||
|
||||
inline void CameraComponent::SetFOV(float fov)
|
||||
{
|
||||
NazaraAssert(!NzNumberEquals(fov, 0.f), "FOV must be different from zero");
|
||||
NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero");
|
||||
m_fov = fov;
|
||||
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
inline void CameraComponent::SetProjectionType(nzProjectionType projectionType)
|
||||
inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType)
|
||||
{
|
||||
m_projectionType = projectionType;
|
||||
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
inline void CameraComponent::SetTarget(const NzRenderTarget* renderTarget)
|
||||
inline void CameraComponent::SetTarget(const Nz::RenderTarget* renderTarget)
|
||||
{
|
||||
m_target = renderTarget;
|
||||
if (m_target)
|
||||
{
|
||||
m_targetResizeSlot.Connect(m_target->OnRenderTargetSizeChange, this, &CameraComponent::OnRenderTargetSizeChange);
|
||||
m_targetReleaseSlot.Connect(m_target->OnRenderTargetRelease, this, &CameraComponent::OnRenderTargetRelease);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_targetResizeSlot.Disconnect();
|
||||
m_targetReleaseSlot.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
inline void CameraComponent::SetTargetRegion(const NzRectf& region)
|
||||
inline void CameraComponent::SetTargetRegion(const Nz::Rectf& region)
|
||||
{
|
||||
m_targetRegion = region;
|
||||
|
||||
InvalidateViewport();
|
||||
}
|
||||
|
||||
inline void CameraComponent::SetViewport(const NzRecti& viewport)
|
||||
inline void CameraComponent::SetViewport(const Nz::Recti& viewport)
|
||||
{
|
||||
NazaraAssert(m_target, "Component has no render target");
|
||||
|
||||
|
|
@ -175,7 +181,7 @@ namespace Ndk
|
|||
float invWidth = 1.f/m_target->GetWidth();
|
||||
float invHeight = 1.f/m_target->GetHeight();
|
||||
|
||||
SetTargetRegion(NzRectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
|
||||
SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
|
||||
}
|
||||
|
||||
inline void CameraComponent::SetZFar(float zFar)
|
||||
|
|
@ -187,7 +193,7 @@ namespace Ndk
|
|||
|
||||
inline void CameraComponent::SetZNear(float zNear)
|
||||
{
|
||||
NazaraAssert(!NzNumberEquals(zNear, 0.f), "zNear cannot be zero");
|
||||
NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero");
|
||||
m_zNear = zNear;
|
||||
|
||||
InvalidateProjectionMatrix();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@
|
|||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
class NzPhysObject;
|
||||
namespace Nz
|
||||
{
|
||||
class PhysObject;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
|
@ -23,30 +26,30 @@ namespace Ndk
|
|||
friend class StaticCollisionSystem;
|
||||
|
||||
public:
|
||||
CollisionComponent(NzPhysGeomRef geom = NzPhysGeomRef());
|
||||
CollisionComponent(Nz::PhysGeomRef geom = Nz::PhysGeomRef());
|
||||
CollisionComponent(const CollisionComponent& collision);
|
||||
~CollisionComponent() = default;
|
||||
|
||||
const NzPhysGeomRef& GetGeom() const;
|
||||
const Nz::PhysGeomRef& GetGeom() const;
|
||||
|
||||
void SetGeom(NzPhysGeomRef geom);
|
||||
void SetGeom(Nz::PhysGeomRef geom);
|
||||
|
||||
CollisionComponent& operator=(NzPhysGeomRef geom);
|
||||
CollisionComponent& operator=(Nz::PhysGeomRef geom);
|
||||
CollisionComponent& operator=(CollisionComponent&& collision) = default;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
void InitializeStaticBody();
|
||||
NzPhysObject* GetStaticBody();
|
||||
Nz::PhysObject* GetStaticBody();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<NzPhysObject> m_staticBody;
|
||||
NzPhysGeomRef m_geom;
|
||||
std::unique_ptr<Nz::PhysObject> m_staticBody;
|
||||
Nz::PhysGeomRef m_geom;
|
||||
bool m_bodyUpdated;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
inline CollisionComponent::CollisionComponent(NzPhysGeomRef geom) :
|
||||
inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) :
|
||||
m_geom(std::move(geom)),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
|
|
@ -21,19 +21,19 @@ namespace Ndk
|
|||
{
|
||||
}
|
||||
|
||||
inline const NzPhysGeomRef& CollisionComponent::GetGeom() const
|
||||
inline const Nz::PhysGeomRef& CollisionComponent::GetGeom() const
|
||||
{
|
||||
return m_geom;
|
||||
}
|
||||
|
||||
inline CollisionComponent& CollisionComponent::operator=(NzPhysGeomRef geom)
|
||||
inline CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom)
|
||||
{
|
||||
SetGeom(geom);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline NzPhysObject* CollisionComponent::GetStaticBody()
|
||||
inline Nz::PhysObject* CollisionComponent::GetStaticBody()
|
||||
{
|
||||
return m_staticBody.get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,16 @@ namespace Ndk
|
|||
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
|
||||
~GraphicsComponent() = default;
|
||||
|
||||
inline void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const;
|
||||
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
||||
|
||||
inline void Attach(NzInstancedRenderableRef renderable);
|
||||
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||
|
||||
inline void EnsureTransformMatrixUpdate() const;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
void InvalidateRenderableData(const NzInstancedRenderable* renderable, nzUInt32 flags, unsigned int index);
|
||||
void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index);
|
||||
inline void InvalidateRenderables();
|
||||
inline void InvalidateTransformMatrix();
|
||||
|
||||
|
|
@ -39,29 +39,29 @@ namespace Ndk
|
|||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
void OnNodeInvalidated(const NzNode* node);
|
||||
void OnNodeInvalidated(const Nz::Node* node);
|
||||
|
||||
void UpdateTransformMatrix() const;
|
||||
|
||||
NazaraSlot(NzNode, OnNodeInvalidation, m_nodeInvalidationSlot);
|
||||
NazaraSlot(Nz::Node, OnNodeInvalidation, m_nodeInvalidationSlot);
|
||||
|
||||
struct Renderable
|
||||
{
|
||||
Renderable(NzMatrix4f& transformMatrix) :
|
||||
Renderable(Nz::Matrix4f& transformMatrix) :
|
||||
data(transformMatrix),
|
||||
dataUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
NazaraSlot(NzInstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
|
||||
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
|
||||
|
||||
mutable NzInstancedRenderable::InstanceData data;
|
||||
NzInstancedRenderableRef renderable;
|
||||
mutable Nz::InstancedRenderable::InstanceData data;
|
||||
Nz::InstancedRenderableRef renderable;
|
||||
mutable bool dataUpdated;
|
||||
};
|
||||
|
||||
std::vector<Renderable> m_renderables;
|
||||
mutable NzMatrix4f m_transformMatrix;
|
||||
mutable Nz::Matrix4f m_transformMatrix;
|
||||
mutable bool m_transformMatrixUpdated;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ namespace Ndk
|
|||
{
|
||||
m_renderables.reserve(graphicsComponent.m_renderables.size());
|
||||
for (const Renderable& r : graphicsComponent.m_renderables)
|
||||
Attach(r.renderable);
|
||||
Attach(r.renderable, r.data.renderOrder);
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
|
||||
inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const
|
||||
{
|
||||
EnsureTransformMatrixUpdate();
|
||||
|
||||
|
|
@ -32,10 +32,11 @@ namespace Ndk
|
|||
}
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::Attach(NzInstancedRenderableRef renderable)
|
||||
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder)
|
||||
{
|
||||
m_renderables.emplace_back(m_transformMatrix);
|
||||
Renderable& r = m_renderables.back();
|
||||
r.data.renderOrder = renderOrder;
|
||||
r.renderable = std::move(renderable);
|
||||
r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LightComponent : public Component<LightComponent>, public NzLight
|
||||
class NDK_API LightComponent : public Component<LightComponent>, public Nz::Light
|
||||
{
|
||||
public:
|
||||
inline LightComponent(nzLightType lightType = nzLightType_Point);
|
||||
inline LightComponent(Nz::LightType lightType = Nz::LightType_Point);
|
||||
LightComponent(const LightComponent& light) = default;
|
||||
~LightComponent() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
inline LightComponent::LightComponent(nzLightType lightType) :
|
||||
NzLight(lightType)
|
||||
inline LightComponent::LightComponent(Nz::LightType lightType) :
|
||||
Nz::Light(lightType)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -14,14 +14,14 @@ namespace Ndk
|
|||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API NodeComponent : public Component<NodeComponent>, public NzNode
|
||||
class NDK_API NodeComponent : public Component<NodeComponent>, public Nz::Node
|
||||
{
|
||||
public:
|
||||
NodeComponent() = default;
|
||||
~NodeComponent() = default;
|
||||
|
||||
void SetParent(Entity* entity, bool keepDerived = false);
|
||||
using NzNode::SetParent;
|
||||
using Nz::Node::SetParent;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ namespace Ndk
|
|||
{
|
||||
NazaraAssert(entity->HasComponent<NodeComponent>(), "Entity must have a NodeComponent");
|
||||
|
||||
NzNode::SetParent(entity->GetComponent<NodeComponent>(), keepDerived);
|
||||
Nz::Node::SetParent(entity->GetComponent<NodeComponent>(), keepDerived);
|
||||
}
|
||||
else
|
||||
NzNode::SetParent(nullptr, keepDerived);
|
||||
Nz::Node::SetParent(nullptr, keepDerived);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,45 +25,45 @@ namespace Ndk
|
|||
PhysicsComponent(const PhysicsComponent& physics);
|
||||
~PhysicsComponent() = default;
|
||||
|
||||
void AddForce(const NzVector3f& force, nzCoordSys coordSys = nzCoordSys_Global);
|
||||
void AddForce(const NzVector3f& force, const NzVector3f& point, nzCoordSys coordSys = nzCoordSys_Global);
|
||||
void AddTorque(const NzVector3f& torque, nzCoordSys coordSys = nzCoordSys_Global);
|
||||
void AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
void AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
void AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
|
||||
void EnableAutoSleep(bool autoSleep);
|
||||
|
||||
NzBoxf GetAABB() const;
|
||||
NzVector3f GetAngularVelocity() const;
|
||||
Nz::Boxf GetAABB() const;
|
||||
Nz::Vector3f GetAngularVelocity() const;
|
||||
float GetGravityFactor() const;
|
||||
float GetMass() const;
|
||||
NzVector3f GetMassCenter(nzCoordSys coordSys = nzCoordSys_Local) const;
|
||||
const NzMatrix4f& GetMatrix() const;
|
||||
NzVector3f GetPosition() const;
|
||||
NzQuaternionf GetRotation() const;
|
||||
NzVector3f GetVelocity() const;
|
||||
Nz::Vector3f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
||||
const Nz::Matrix4f& GetMatrix() const;
|
||||
Nz::Vector3f GetPosition() const;
|
||||
Nz::Quaternionf GetRotation() const;
|
||||
Nz::Vector3f GetVelocity() const;
|
||||
|
||||
bool IsAutoSleepEnabled() const;
|
||||
bool IsMoveable() const;
|
||||
bool IsSleeping() const;
|
||||
|
||||
void SetAngularVelocity(const NzVector3f& angularVelocity);
|
||||
void SetAngularVelocity(const Nz::Vector3f& angularVelocity);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const NzVector3f& center);
|
||||
void SetPosition(const NzVector3f& position);
|
||||
void SetRotation(const NzQuaternionf& rotation);
|
||||
void SetVelocity(const NzVector3f& velocity);
|
||||
void SetMassCenter(const Nz::Vector3f& center);
|
||||
void SetPosition(const Nz::Vector3f& position);
|
||||
void SetRotation(const Nz::Quaternionf& rotation);
|
||||
void SetVelocity(const Nz::Vector3f& velocity);
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
NzPhysObject& GetPhysObject();
|
||||
Nz::PhysObject& GetPhysObject();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<NzPhysObject> m_object;
|
||||
std::unique_ptr<Nz::PhysObject> m_object;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,21 +12,21 @@ namespace Ndk
|
|||
NazaraUnused(physics);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::AddForce(const NzVector3f& force, nzCoordSys coordSys)
|
||||
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->AddForce(force, coordSys);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::AddForce(const NzVector3f& force, const NzVector3f& point, nzCoordSys coordSys)
|
||||
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->AddForce(force, point, coordSys);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::AddTorque(const NzVector3f& torque, nzCoordSys coordSys)
|
||||
inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
|
|
@ -40,14 +40,14 @@ namespace Ndk
|
|||
m_object->EnableAutoSleep(autoSleep);
|
||||
}
|
||||
|
||||
inline NzBoxf PhysicsComponent::GetAABB() const
|
||||
inline Nz::Boxf PhysicsComponent::GetAABB() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetAABB();
|
||||
}
|
||||
|
||||
inline NzVector3f PhysicsComponent::GetAngularVelocity() const
|
||||
inline Nz::Vector3f PhysicsComponent::GetAngularVelocity() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
|
|
@ -68,35 +68,35 @@ namespace Ndk
|
|||
return m_object->GetMass();
|
||||
}
|
||||
|
||||
inline NzVector3f PhysicsComponent::GetMassCenter(nzCoordSys coordSys) const
|
||||
inline Nz::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetMassCenter(coordSys);
|
||||
}
|
||||
|
||||
inline const NzMatrix4f& PhysicsComponent::GetMatrix() const
|
||||
inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetMatrix();
|
||||
}
|
||||
|
||||
inline NzVector3f PhysicsComponent::GetPosition() const
|
||||
inline Nz::Vector3f PhysicsComponent::GetPosition() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetPosition();
|
||||
}
|
||||
|
||||
inline NzQuaternionf PhysicsComponent::GetRotation() const
|
||||
inline Nz::Quaternionf PhysicsComponent::GetRotation() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetRotation();
|
||||
}
|
||||
|
||||
inline NzVector3f PhysicsComponent::GetVelocity() const
|
||||
inline Nz::Vector3f PhysicsComponent::GetVelocity() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ namespace Ndk
|
|||
return m_object->IsSleeping();
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::SetAngularVelocity(const NzVector3f& angularVelocity)
|
||||
inline void PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
|
|
@ -139,35 +139,35 @@ namespace Ndk
|
|||
m_object->SetMass(mass);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::SetMassCenter(const NzVector3f& center)
|
||||
inline void PhysicsComponent::SetMassCenter(const Nz::Vector3f& center)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetMassCenter(center);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::SetPosition(const NzVector3f& position)
|
||||
inline void PhysicsComponent::SetPosition(const Nz::Vector3f& position)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetPosition(position);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::SetRotation(const NzQuaternionf& rotation)
|
||||
inline void PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetRotation(rotation);
|
||||
}
|
||||
|
||||
inline void PhysicsComponent::SetVelocity(const NzVector3f& velocity)
|
||||
inline void PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetVelocity(velocity);
|
||||
}
|
||||
|
||||
inline NzPhysObject& PhysicsComponent::GetPhysObject()
|
||||
inline Nz::PhysObject& PhysicsComponent::GetPhysObject()
|
||||
{
|
||||
return *m_object.get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ namespace Ndk
|
|||
class NDK_API VelocityComponent : public Component<VelocityComponent>
|
||||
{
|
||||
public:
|
||||
VelocityComponent(const NzVector3f& velocity = NzVector3f::Zero());
|
||||
VelocityComponent(const Nz::Vector3f& velocity = Nz::Vector3f::Zero());
|
||||
~VelocityComponent() = default;
|
||||
|
||||
NzVector3f linearVelocity;
|
||||
Nz::Vector3f linearVelocity;
|
||||
|
||||
VelocityComponent& operator=(const NzVector3f& vel);
|
||||
VelocityComponent& operator=(const Nz::Vector3f& vel);
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
inline VelocityComponent::VelocityComponent(const NzVector3f& velocity) :
|
||||
inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity) :
|
||||
linearVelocity(velocity)
|
||||
{
|
||||
}
|
||||
|
||||
inline VelocityComponent& VelocityComponent::operator=(const NzVector3f& vel)
|
||||
inline VelocityComponent& VelocityComponent::operator=(const Nz::Vector3f& vel)
|
||||
{
|
||||
linearVelocity = vel;
|
||||
return *this;
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ namespace Ndk
|
|||
|
||||
inline BaseComponent& GetComponent(ComponentIndex index);
|
||||
template<typename ComponentType> ComponentType& GetComponent();
|
||||
inline const NzBitset<>& GetComponentBits() const;
|
||||
inline const Nz::Bitset<>& GetComponentBits() const;
|
||||
inline EntityId GetId() const;
|
||||
inline const NzBitset<>& GetSystemBits() const;
|
||||
inline const Nz::Bitset<>& GetSystemBits() const;
|
||||
inline World* GetWorld() const;
|
||||
|
||||
inline bool HasComponent(ComponentIndex index) const;
|
||||
|
|
@ -69,9 +69,9 @@ namespace Ndk
|
|||
|
||||
std::vector<std::unique_ptr<BaseComponent>> m_components;
|
||||
std::vector<EntityHandle*> m_handles;
|
||||
Nz::Bitset<> m_componentBits;
|
||||
Nz::Bitset<> m_systemBits;
|
||||
EntityId m_id;
|
||||
NzBitset<> m_componentBits;
|
||||
NzBitset<> m_systemBits;
|
||||
World* m_world;
|
||||
bool m_valid;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Ndk
|
|||
return static_cast<ComponentType&>(GetComponent(index));
|
||||
}
|
||||
|
||||
inline const NzBitset<>& Entity::GetComponentBits() const
|
||||
inline const Nz::Bitset<>& Entity::GetComponentBits() const
|
||||
{
|
||||
return m_componentBits;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ namespace Ndk
|
|||
return m_id;
|
||||
}
|
||||
|
||||
inline const NzBitset<>& Entity::GetSystemBits() const
|
||||
inline const Nz::Bitset<>& Entity::GetSystemBits() const
|
||||
{
|
||||
return m_systemBits;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Ndk
|
|||
|
||||
EntityHandle& Swap(EntityHandle& handle);
|
||||
|
||||
NzString ToString() const;
|
||||
Nz::String ToString() const;
|
||||
|
||||
operator bool() const;
|
||||
operator Entity*() const;
|
||||
|
|
|
|||
|
|
@ -90,9 +90,9 @@ namespace Ndk
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline NzString EntityHandle::ToString() const
|
||||
inline Nz::String EntityHandle::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
Nz::StringStream ss;
|
||||
ss << "EntityHandle(";
|
||||
if (IsValid())
|
||||
ss << "Entity(" << m_entity->GetId() << ')';
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Ndk
|
|||
|
||||
private:
|
||||
std::vector<EntityHandle> m_entities;
|
||||
NzBitset<nzUInt64> m_entityBits;
|
||||
Nz::Bitset<Nz::UInt64> m_entityBits;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Ndk
|
|||
}
|
||||
}
|
||||
|
||||
// Interface STD
|
||||
// Nz::Interface STD
|
||||
inline EntityList::Container::iterator EntityList::begin()
|
||||
{
|
||||
return m_entities.begin();
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
using ComponentId = nzUInt64;
|
||||
using ComponentIndex = nzUInt32;
|
||||
using EntityId = nzUInt32;
|
||||
using SystemIndex = nzUInt32;
|
||||
using ComponentId = Nz::UInt64;
|
||||
using ComponentIndex = Nz::UInt32;
|
||||
using EntityId = Nz::UInt32;
|
||||
using SystemIndex = Nz::UInt32;
|
||||
}
|
||||
|
||||
#endif // NDK_PREREQUESITES_HPP
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ namespace Ndk
|
|||
PhysicsSystem(const PhysicsSystem& system);
|
||||
~PhysicsSystem() = default;
|
||||
|
||||
NzPhysWorld& GetWorld();
|
||||
const NzPhysWorld& GetWorld() const;
|
||||
Nz::PhysWorld& GetWorld();
|
||||
const Nz::PhysWorld& GetWorld() const;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ namespace Ndk
|
|||
|
||||
EntityList m_dynamicObjects;
|
||||
EntityList m_staticObjects;
|
||||
NzPhysWorld m_world;
|
||||
Nz::PhysWorld m_world;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
inline NzPhysWorld& PhysicsSystem::GetWorld()
|
||||
inline Nz::PhysWorld& PhysicsSystem::GetWorld()
|
||||
{
|
||||
return m_world;
|
||||
}
|
||||
|
||||
inline const NzPhysWorld& PhysicsSystem::GetWorld() const
|
||||
inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const
|
||||
{
|
||||
return m_world;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ namespace Ndk
|
|||
inline RenderSystem(const RenderSystem& renderSystem);
|
||||
~RenderSystem() = default;
|
||||
|
||||
inline const NzBackgroundRef& GetDefaultBackground() const;
|
||||
inline const NzMatrix4f& GetCoordinateSystemMatrix() const;
|
||||
inline NzVector3f GetGlobalForward() const;
|
||||
inline NzVector3f GetGlobalRight() const;
|
||||
inline NzVector3f GetGlobalUp() const;
|
||||
inline const Nz::BackgroundRef& GetDefaultBackground() const;
|
||||
inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;
|
||||
inline Nz::Vector3f GetGlobalForward() const;
|
||||
inline Nz::Vector3f GetGlobalRight() const;
|
||||
inline Nz::Vector3f GetGlobalUp() const;
|
||||
|
||||
inline void SetDefaultBackground(NzBackgroundRef background);
|
||||
inline void SetGlobalForward(const NzVector3f& direction);
|
||||
inline void SetGlobalRight(const NzVector3f& direction);
|
||||
inline void SetGlobalUp(const NzVector3f& direction);
|
||||
inline void SetDefaultBackground(Nz::BackgroundRef background);
|
||||
inline void SetGlobalForward(const Nz::Vector3f& direction);
|
||||
inline void SetGlobalRight(const Nz::Vector3f& direction);
|
||||
inline void SetGlobalUp(const Nz::Vector3f& direction);
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ namespace Ndk
|
|||
void OnEntityRemoved(Entity* entity) override;
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
void UpdateDirectionalShadowMaps(const NzAbstractViewer& viewer);
|
||||
void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer);
|
||||
void UpdatePointSpotShadowMaps();
|
||||
|
||||
EntityList m_cameras;
|
||||
|
|
@ -54,11 +54,11 @@ namespace Ndk
|
|||
EntityList m_directionalLights;
|
||||
EntityList m_lights;
|
||||
EntityList m_pointSpotLights;
|
||||
NzBackgroundRef m_background;
|
||||
NzDepthRenderTechnique m_shadowTechnique;
|
||||
NzForwardRenderTechnique m_renderTechnique;
|
||||
NzMatrix4f m_coordinateSystemMatrix;
|
||||
NzRenderTexture m_shadowRT;
|
||||
Nz::BackgroundRef m_background;
|
||||
Nz::DepthRenderTechnique m_shadowTechnique;
|
||||
Nz::ForwardRenderTechnique m_renderTechnique;
|
||||
Nz::Matrix4f m_coordinateSystemMatrix;
|
||||
Nz::RenderTexture m_shadowRT;
|
||||
bool m_coordinateSystemInvalidated;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,37 +9,37 @@ namespace Ndk
|
|||
{
|
||||
}
|
||||
|
||||
inline const NzBackgroundRef& RenderSystem::GetDefaultBackground() const
|
||||
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const
|
||||
{
|
||||
return m_background;
|
||||
}
|
||||
|
||||
inline const NzMatrix4f& RenderSystem::GetCoordinateSystemMatrix() const
|
||||
inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const
|
||||
{
|
||||
return m_coordinateSystemMatrix;
|
||||
}
|
||||
|
||||
inline NzVector3f RenderSystem::GetGlobalForward() const
|
||||
inline Nz::Vector3f RenderSystem::GetGlobalForward() const
|
||||
{
|
||||
return NzVector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
|
||||
return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
|
||||
}
|
||||
|
||||
inline NzVector3f RenderSystem::GetGlobalRight() const
|
||||
inline Nz::Vector3f RenderSystem::GetGlobalRight() const
|
||||
{
|
||||
return NzVector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
|
||||
return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
|
||||
}
|
||||
|
||||
inline NzVector3f RenderSystem::GetGlobalUp() const
|
||||
inline Nz::Vector3f RenderSystem::GetGlobalUp() const
|
||||
{
|
||||
return NzVector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
|
||||
return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
|
||||
}
|
||||
|
||||
inline void RenderSystem::SetDefaultBackground(NzBackgroundRef background)
|
||||
inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background)
|
||||
{
|
||||
m_background = std::move(background);
|
||||
}
|
||||
|
||||
inline void RenderSystem::SetGlobalForward(const NzVector3f& direction)
|
||||
inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction)
|
||||
{
|
||||
m_coordinateSystemMatrix.m13 = -direction.x;
|
||||
m_coordinateSystemMatrix.m23 = -direction.y;
|
||||
|
|
@ -48,7 +48,7 @@ namespace Ndk
|
|||
InvalidateCoordinateSystem();
|
||||
}
|
||||
|
||||
inline void RenderSystem::SetGlobalRight(const NzVector3f& direction)
|
||||
inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction)
|
||||
{
|
||||
m_coordinateSystemMatrix.m11 = direction.x;
|
||||
m_coordinateSystemMatrix.m21 = direction.y;
|
||||
|
|
@ -57,7 +57,7 @@ namespace Ndk
|
|||
InvalidateCoordinateSystem();
|
||||
}
|
||||
|
||||
inline void RenderSystem::SetGlobalUp(const NzVector3f& direction)
|
||||
inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction)
|
||||
{
|
||||
m_coordinateSystemMatrix.m12 = direction.x;
|
||||
m_coordinateSystemMatrix.m22 = direction.y;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#define NDK_WORLD_HPP
|
||||
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/EntityHandle.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
|
|
@ -19,7 +18,7 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API World : NzNonCopyable
|
||||
class NDK_API World
|
||||
{
|
||||
friend Entity;
|
||||
|
||||
|
|
@ -27,6 +26,8 @@ namespace Ndk
|
|||
using EntityList = std::vector<EntityHandle>;
|
||||
|
||||
inline World(bool addDefaultSystems = true);
|
||||
World(const World&) = delete;
|
||||
World(World&&) = delete; ///TODO
|
||||
~World();
|
||||
|
||||
void AddDefaultSystems();
|
||||
|
|
@ -60,6 +61,9 @@ namespace Ndk
|
|||
void Update();
|
||||
inline void Update(float elapsedTime);
|
||||
|
||||
World& operator=(const World&) = delete;
|
||||
World& operator=(World&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
inline void Invalidate();
|
||||
inline void Invalidate(EntityId id);
|
||||
|
|
@ -81,8 +85,8 @@ namespace Ndk
|
|||
std::vector<EntityBlock> m_entities;
|
||||
std::vector<EntityId> m_freeIdList;
|
||||
EntityList m_aliveEntities;
|
||||
NzBitset<nzUInt64> m_dirtyEntities;
|
||||
NzBitset<nzUInt64> m_killedEntities;
|
||||
Nz::Bitset<Nz::UInt64> m_dirtyEntities;
|
||||
Nz::Bitset<Nz::UInt64> m_killedEntities;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,8 +136,11 @@ namespace Ndk
|
|||
|
||||
// And then update systems
|
||||
for (auto& systemPtr : m_systems)
|
||||
{
|
||||
if (systemPtr)
|
||||
systemPtr->Update(elapsedTime);
|
||||
}
|
||||
}
|
||||
|
||||
inline void World::Invalidate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Ndk
|
|||
if (!entity)
|
||||
return false;
|
||||
|
||||
const NzBitset<>& components = entity->GetComponentBits();
|
||||
const Nz::Bitset<>& components = entity->GetComponentBits();
|
||||
|
||||
m_filterResult.PerformsAND(m_requiredComponents, components);
|
||||
if (m_filterResult != m_requiredComponents)
|
||||
|
|
|
|||
|
|
@ -17,20 +17,20 @@ namespace Ndk
|
|||
EnsureViewMatrixUpdate();
|
||||
EnsureViewportUpdate();
|
||||
|
||||
NzRenderer::SetMatrix(nzMatrixType_Projection, m_projectionMatrix);
|
||||
NzRenderer::SetMatrix(nzMatrixType_View, m_viewMatrix);
|
||||
NzRenderer::SetTarget(m_target);
|
||||
NzRenderer::SetViewport(m_viewport);
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, m_projectionMatrix);
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_View, m_viewMatrix);
|
||||
Nz::Renderer::SetTarget(m_target);
|
||||
Nz::Renderer::SetViewport(m_viewport);
|
||||
}
|
||||
|
||||
NzVector3f CameraComponent::GetEyePosition() const
|
||||
Nz::Vector3f CameraComponent::GetEyePosition() const
|
||||
{
|
||||
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
||||
|
||||
return m_entity->GetComponent<NodeComponent>().GetPosition();
|
||||
}
|
||||
|
||||
NzVector3f CameraComponent::GetForward() const
|
||||
Nz::Vector3f CameraComponent::GetForward() const
|
||||
{
|
||||
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ namespace Ndk
|
|||
InvalidateViewMatrix();
|
||||
}
|
||||
|
||||
void CameraComponent::OnNodeInvalidated(const NzNode* node)
|
||||
void CameraComponent::OnNodeInvalidated(const Nz::Node* node)
|
||||
{
|
||||
NazaraUnused(node);
|
||||
|
||||
|
|
@ -88,20 +88,20 @@ namespace Ndk
|
|||
InvalidateViewMatrix();
|
||||
}
|
||||
|
||||
void CameraComponent::OnRenderTargetRelease(const NzRenderTarget* renderTarget)
|
||||
void CameraComponent::OnRenderTargetRelease(const Nz::RenderTarget* renderTarget)
|
||||
{
|
||||
if (renderTarget == m_target)
|
||||
m_target = nullptr;
|
||||
else
|
||||
NazaraInternalError("Not listening to " + NzString::Pointer(renderTarget));
|
||||
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
|
||||
}
|
||||
|
||||
void CameraComponent::OnRenderTargetSizeChange(const NzRenderTarget* renderTarget)
|
||||
void CameraComponent::OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget)
|
||||
{
|
||||
if (renderTarget == m_target)
|
||||
InvalidateViewport();
|
||||
else
|
||||
NazaraInternalError("Not listening to " + NzString::Pointer(renderTarget));
|
||||
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
|
||||
}
|
||||
|
||||
void CameraComponent::UpdateFrustum() const
|
||||
|
|
@ -118,13 +118,13 @@ namespace Ndk
|
|||
{
|
||||
switch (m_projectionType)
|
||||
{
|
||||
case nzProjectionType_Orthogonal:
|
||||
case Nz::ProjectionType_Orthogonal:
|
||||
EnsureViewportUpdate();
|
||||
|
||||
m_projectionMatrix.MakeOrtho(0.f, static_cast<float>(m_viewport.width), 0.f, static_cast<float>(m_viewport.height), m_zNear, m_zFar);
|
||||
break;
|
||||
|
||||
case nzProjectionType_Perspective:
|
||||
case Nz::ProjectionType_Perspective:
|
||||
EnsureViewportUpdate(); // Can affect aspect ratio
|
||||
|
||||
m_projectionMatrix.MakePerspective(m_fov, m_aspectRatio, m_zNear, m_zFar);
|
||||
|
|
@ -141,7 +141,7 @@ namespace Ndk
|
|||
NodeComponent& nodeComponent = m_entity->GetComponent<NodeComponent>();
|
||||
|
||||
// Build the view matrix using the NodeComponent position/rotation
|
||||
m_viewMatrix.MakeViewMatrix(nodeComponent.GetPosition(nzCoordSys_Global), nodeComponent.GetRotation(nzCoordSys_Global));
|
||||
m_viewMatrix.MakeViewMatrix(nodeComponent.GetPosition(Nz::CoordSys_Global), nodeComponent.GetRotation(Nz::CoordSys_Global));
|
||||
m_viewMatrixUpdated = true;
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ namespace Ndk
|
|||
unsigned int targetHeight = std::max(m_target->GetHeight(), 1U); // Let's make sure we won't divide by zero
|
||||
|
||||
// Our target region is expressed as % of the viewport dimensions, let's compute it in pixels
|
||||
NzRectf fViewport(m_targetRegion);
|
||||
Nz::Rectf fViewport(m_targetRegion);
|
||||
fViewport.x *= targetWidth;
|
||||
fViewport.y *= targetHeight;
|
||||
fViewport.width *= targetWidth;
|
||||
|
|
@ -161,11 +161,11 @@ namespace Ndk
|
|||
|
||||
// Compute the new aspect ratio, if it's different we need to invalidate the projection matrix
|
||||
float aspectRatio = fViewport.width/fViewport.height;
|
||||
if (!NzNumberEquals(m_aspectRatio, aspectRatio, 0.001f))
|
||||
if (!Nz::NumberEquals(m_aspectRatio, aspectRatio, 0.001f))
|
||||
{
|
||||
m_aspectRatio = aspectRatio;
|
||||
|
||||
if (m_projectionType == nzProjectionType_Perspective)
|
||||
if (m_projectionType == Nz::ProjectionType_Perspective)
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
void CollisionComponent::SetGeom(NzPhysGeomRef geom)
|
||||
void CollisionComponent::SetGeom(Nz::PhysGeomRef geom)
|
||||
{
|
||||
m_geom = std::move(geom);
|
||||
|
||||
|
|
@ -35,9 +35,9 @@ namespace Ndk
|
|||
|
||||
NazaraAssert(entityWorld, "Entity must have world");
|
||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
||||
NzPhysWorld& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
Nz::PhysWorld& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
|
||||
m_staticBody.reset(new NzPhysObject(&physWorld, m_geom));
|
||||
m_staticBody.reset(new Nz::PhysObject(&physWorld, m_geom));
|
||||
m_staticBody->EnableAutoSleep(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
void GraphicsComponent::InvalidateRenderableData(const NzInstancedRenderable* renderable, nzUInt32 flags, unsigned int index)
|
||||
void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index)
|
||||
{
|
||||
NazaraAssert(index < m_renderables.size(), "Invalid renderable index");
|
||||
NazaraUnused(renderable);
|
||||
|
|
@ -55,7 +55,7 @@ namespace Ndk
|
|||
InvalidateTransformMatrix();
|
||||
}
|
||||
|
||||
void GraphicsComponent::OnNodeInvalidated(const NzNode* node)
|
||||
void GraphicsComponent::OnNodeInvalidated(const Nz::Node* node)
|
||||
{
|
||||
NazaraUnused(node);
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ namespace Ndk
|
|||
|
||||
Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem<Ndk::RenderSystem>();
|
||||
|
||||
m_transformMatrix = NzMatrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent<NodeComponent>().GetTransformMatrix());
|
||||
m_transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent<NodeComponent>().GetTransformMatrix());
|
||||
m_transformMatrixUpdated = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ namespace Ndk
|
|||
World* entityWorld = m_entity->GetWorld();
|
||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
||||
|
||||
NzPhysWorld& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
Nz::PhysWorld& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
|
||||
NzPhysGeomRef geom;
|
||||
Nz::PhysGeomRef geom;
|
||||
if (m_entity->HasComponent<CollisionComponent>())
|
||||
geom = m_entity->GetComponent<CollisionComponent>().GetGeom();
|
||||
|
||||
NzMatrix4f matrix;
|
||||
Nz::Matrix4f matrix;
|
||||
if (m_entity->HasComponent<NodeComponent>())
|
||||
matrix = m_entity->GetComponent<NodeComponent>().GetTransformMatrix();
|
||||
else
|
||||
matrix.MakeIdentity();
|
||||
|
||||
m_object.reset(new NzPhysObject(&world, geom, matrix));
|
||||
m_object.reset(new Nz::PhysObject(&world, geom, matrix));
|
||||
m_object->SetMass(1.f);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ namespace Ndk
|
|||
if (IsComponent<CollisionComponent>(component))
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid object");
|
||||
m_object->SetGeom(NzNullGeom::New());
|
||||
m_object->SetGeom(Nz::NullGeom::New());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ namespace Ndk
|
|||
Entity::Entity(Entity&& entity) :
|
||||
m_components(std::move(entity.m_components)),
|
||||
m_handles(std::move(entity.m_handles)),
|
||||
m_id(entity.m_id),
|
||||
m_componentBits(std::move(entity.m_componentBits)),
|
||||
m_systemBits(std::move(entity.m_systemBits)),
|
||||
m_id(entity.m_id),
|
||||
m_world(entity.m_world),
|
||||
m_valid(entity.m_valid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,19 +35,19 @@ namespace Ndk
|
|||
|
||||
try
|
||||
{
|
||||
NzErrorFlags errFlags(nzErrorFlag_ThrowException, true);
|
||||
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
|
||||
|
||||
// Initialisation du moteur
|
||||
|
||||
// Modules clients
|
||||
NzAudio::Initialize();
|
||||
NzGraphics::Initialize();
|
||||
Nz::Audio::Initialize();
|
||||
Nz::Graphics::Initialize();
|
||||
|
||||
// Modules serveurs
|
||||
NzLua::Initialize();
|
||||
NzNoise::Initialize();
|
||||
NzPhysics::Initialize();
|
||||
NzUtility::Initialize();
|
||||
Nz::Lua::Initialize();
|
||||
Nz::Noise::Initialize();
|
||||
Nz::Physics::Initialize();
|
||||
Nz::Utility::Initialize();
|
||||
|
||||
// Initialisation du SDK
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ namespace Ndk
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraError("Failed to initialize NDK: " + NzString(e.what()));
|
||||
NazaraError("Failed to initialize NDK: " + Nz::String(e.what()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -99,14 +99,14 @@ namespace Ndk
|
|||
// Libération du moteur
|
||||
|
||||
// Modules clients
|
||||
NzAudio::Uninitialize();
|
||||
NzGraphics::Uninitialize();
|
||||
Nz::Audio::Uninitialize();
|
||||
Nz::Graphics::Uninitialize();
|
||||
|
||||
// Modules serveurs
|
||||
NzLua::Uninitialize();
|
||||
NzNoise::Uninitialize();
|
||||
NzPhysics::Uninitialize();
|
||||
NzUtility::Uninitialize();
|
||||
Nz::Lua::Uninitialize();
|
||||
Nz::Noise::Uninitialize();
|
||||
Nz::Physics::Uninitialize();
|
||||
Nz::Utility::Uninitialize();
|
||||
|
||||
NazaraNotice("Uninitialized: SDK");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,22 +30,22 @@ namespace Ndk
|
|||
|
||||
// On récupère la position et la rotation pour les affecter au listener
|
||||
const NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
NzAudio::SetListenerPosition(node.GetPosition(nzCoordSys_Global));
|
||||
NzAudio::SetListenerRotation(node.GetRotation(nzCoordSys_Global));
|
||||
Nz::Audio::SetListenerPosition(node.GetPosition(Nz::CoordSys_Global));
|
||||
Nz::Audio::SetListenerRotation(node.GetRotation(Nz::CoordSys_Global));
|
||||
|
||||
// On vérifie la présence d'une donnée de vitesse, et on l'affecte
|
||||
// (La vitesse du listener Audio ne le fait pas se déplacer, mais affecte par exemple l'effet Doppler)
|
||||
if (entity->HasComponent<VelocityComponent>())
|
||||
{
|
||||
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
|
||||
NzAudio::SetListenerVelocity(velocity.linearVelocity);
|
||||
Nz::Audio::SetListenerVelocity(velocity.linearVelocity);
|
||||
}
|
||||
|
||||
activeListenerCount++;
|
||||
}
|
||||
|
||||
if (activeListenerCount > 1)
|
||||
NazaraWarning(NzString::Number(activeListenerCount) + " listeners were active in the same update loop");
|
||||
NazaraWarning(Nz::String::Number(activeListenerCount) + " listeners were active in the same update loop");
|
||||
}
|
||||
|
||||
SystemIndex ListenerSystem::systemIndex;
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ namespace Ndk
|
|||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
PhysicsComponent& phys = entity->GetComponent<PhysicsComponent>();
|
||||
|
||||
NzPhysObject& physObj = phys.GetPhysObject();
|
||||
node.SetRotation(physObj.GetRotation(), nzCoordSys_Global);
|
||||
node.SetPosition(physObj.GetPosition(), nzCoordSys_Global);
|
||||
Nz::PhysObject& physObj = phys.GetPhysObject();
|
||||
node.SetRotation(physObj.GetRotation(), Nz::CoordSys_Global);
|
||||
node.SetPosition(physObj.GetPosition(), Nz::CoordSys_Global);
|
||||
}
|
||||
|
||||
float invElapsedTime = 1.f / elapsedTime;
|
||||
|
|
@ -56,12 +56,12 @@ namespace Ndk
|
|||
CollisionComponent& collision = entity->GetComponent<CollisionComponent>();
|
||||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
|
||||
NzPhysObject* physObj = collision.GetStaticBody();
|
||||
Nz::PhysObject* physObj = collision.GetStaticBody();
|
||||
|
||||
NzQuaternionf oldRotation = physObj->GetRotation();
|
||||
NzVector3f oldPosition = physObj->GetPosition();
|
||||
NzQuaternionf newRotation = node.GetRotation(nzCoordSys_Global);
|
||||
NzVector3f newPosition = node.GetPosition(nzCoordSys_Global);
|
||||
Nz::Quaternionf oldRotation = physObj->GetRotation();
|
||||
Nz::Vector3f oldPosition = physObj->GetPosition();
|
||||
Nz::Quaternionf newRotation = node.GetRotation(Nz::CoordSys_Global);
|
||||
Nz::Vector3f newPosition = node.GetPosition(Nz::CoordSys_Global);
|
||||
|
||||
// Pour déplacer des objets statiques et assurer les collisions, il faut leur définir une vitesse
|
||||
// (note importante: le moteur physique n'applique pas la vitesse sur les objets statiques)
|
||||
|
|
@ -71,21 +71,21 @@ namespace Ndk
|
|||
physObj->SetVelocity((newPosition - oldPosition) * invElapsedTime);
|
||||
}
|
||||
else
|
||||
physObj->SetVelocity(NzVector3f::Zero());
|
||||
physObj->SetVelocity(Nz::Vector3f::Zero());
|
||||
|
||||
if (newRotation != oldRotation)
|
||||
{
|
||||
NzQuaternionf transition = newRotation * oldRotation.GetConjugate();
|
||||
NzEulerAnglesf angles = transition.ToEulerAngles();
|
||||
NzVector3f angularVelocity(NzToRadians(angles.pitch * invElapsedTime),
|
||||
NzToRadians(angles.yaw * invElapsedTime),
|
||||
NzToRadians(angles.roll * invElapsedTime));
|
||||
Nz::Quaternionf transition = newRotation * oldRotation.GetConjugate();
|
||||
Nz::EulerAnglesf angles = transition.ToEulerAngles();
|
||||
Nz::Vector3f angularVelocity(Nz::ToRadians(angles.pitch * invElapsedTime),
|
||||
Nz::ToRadians(angles.yaw * invElapsedTime),
|
||||
Nz::ToRadians(angles.roll * invElapsedTime));
|
||||
|
||||
physObj->SetRotation(oldRotation);
|
||||
physObj->SetAngularVelocity(angularVelocity);
|
||||
}
|
||||
else
|
||||
physObj->SetAngularVelocity(NzVector3f::Zero());
|
||||
physObj->SetAngularVelocity(Nz::Vector3f::Zero());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
namespace Ndk
|
||||
{
|
||||
RenderSystem::RenderSystem() :
|
||||
m_coordinateSystemMatrix(NzMatrix4f::Identity()),
|
||||
m_coordinateSystemMatrix(Nz::Matrix4f::Identity()),
|
||||
m_coordinateSystemInvalidated(true)
|
||||
{
|
||||
SetDefaultBackground(NzColorBackground::New());
|
||||
SetDefaultBackground(Nz::ColorBackground::New());
|
||||
SetUpdateRate(0.f);
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ namespace Ndk
|
|||
if (entity->HasComponent<LightComponent>() && entity->HasComponent<NodeComponent>())
|
||||
{
|
||||
LightComponent& lightComponent = entity->GetComponent<LightComponent>();
|
||||
if (lightComponent.GetLightType() == nzLightType_Directional)
|
||||
if (lightComponent.GetLightType() == Nz::LightType_Directional)
|
||||
{
|
||||
m_directionalLights.Insert(entity);
|
||||
m_pointSpotLights.Remove(entity);
|
||||
|
|
@ -95,7 +95,7 @@ namespace Ndk
|
|||
|
||||
//UpdateDirectionalShadowMaps(camComponent);
|
||||
|
||||
NzAbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
|
||||
Nz::AbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
|
||||
renderQueue->Clear();
|
||||
|
||||
//TODO: Culling
|
||||
|
|
@ -113,13 +113,13 @@ namespace Ndk
|
|||
NodeComponent& lightNode = light->GetComponent<NodeComponent>();
|
||||
|
||||
///TODO: Cache somehow?
|
||||
lightComponent.AddToRenderQueue(renderQueue, NzMatrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix()));
|
||||
lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix()));
|
||||
}
|
||||
|
||||
camComponent.ApplyView();
|
||||
|
||||
NzSceneData sceneData;
|
||||
sceneData.ambientColor = NzColor(25, 25, 25);
|
||||
Nz::SceneData sceneData;
|
||||
sceneData.ambientColor = Nz::Color(25, 25, 25);
|
||||
sceneData.background = m_background;
|
||||
sceneData.viewer = &camComponent;
|
||||
|
||||
|
|
@ -127,13 +127,13 @@ namespace Ndk
|
|||
}
|
||||
}
|
||||
|
||||
void RenderSystem::UpdateDirectionalShadowMaps(const NzAbstractViewer& viewer)
|
||||
void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer)
|
||||
{
|
||||
if (!m_shadowRT.IsValid())
|
||||
m_shadowRT.Create();
|
||||
|
||||
NzSceneData dummySceneData;
|
||||
dummySceneData.ambientColor = NzColor(0, 0, 0);
|
||||
Nz::SceneData dummySceneData;
|
||||
dummySceneData.ambientColor = Nz::Color(0, 0, 0);
|
||||
dummySceneData.background = nullptr;
|
||||
dummySceneData.viewer = nullptr; //< Depth technique doesn't require any viewer
|
||||
|
||||
|
|
@ -145,13 +145,13 @@ namespace Ndk
|
|||
if (!lightComponent.IsShadowCastingEnabled())
|
||||
continue;
|
||||
|
||||
NzVector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
|
||||
Nz::Vector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
|
||||
|
||||
m_shadowRT.AttachTexture(nzAttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
|
||||
NzRenderer::SetTarget(&m_shadowRT);
|
||||
NzRenderer::SetViewport(NzRecti(0, 0, shadowMapSize.x, shadowMapSize.y));
|
||||
m_shadowRT.AttachTexture(Nz::AttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
|
||||
Nz::Renderer::SetTarget(&m_shadowRT);
|
||||
Nz::Renderer::SetViewport(Nz::Recti(0, 0, shadowMapSize.x, shadowMapSize.y));
|
||||
|
||||
NzAbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
|
||||
Nz::AbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
|
||||
renderQueue->Clear();
|
||||
|
||||
///TODO: Culling
|
||||
|
|
@ -164,8 +164,8 @@ namespace Ndk
|
|||
}
|
||||
|
||||
///TODO: Cache the matrices in the light?
|
||||
NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Ortho(0.f, 100.f, 100.f, 0.f, 1.f, 100.f));
|
||||
NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::ViewMatrix(lightNode.GetRotation() * NzVector3f::Forward() * 100.f, lightNode.GetRotation()));
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, Nz::Matrix4f::Ortho(0.f, 100.f, 100.f, 0.f, 1.f, 100.f));
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_View, Nz::Matrix4f::ViewMatrix(lightNode.GetRotation() * Nz::Vector3f::Forward() * 100.f, lightNode.GetRotation()));
|
||||
|
||||
m_shadowTechnique.Draw(dummySceneData);
|
||||
}
|
||||
|
|
@ -176,8 +176,8 @@ namespace Ndk
|
|||
if (!m_shadowRT.IsValid())
|
||||
m_shadowRT.Create();
|
||||
|
||||
NzSceneData dummySceneData;
|
||||
dummySceneData.ambientColor = NzColor(0, 0, 0);
|
||||
Nz::SceneData dummySceneData;
|
||||
dummySceneData.ambientColor = Nz::Color(0, 0, 0);
|
||||
dummySceneData.background = nullptr;
|
||||
dummySceneData.viewer = nullptr; //< Depth technique doesn't require any viewer
|
||||
|
||||
|
|
@ -189,37 +189,37 @@ namespace Ndk
|
|||
if (!lightComponent.IsShadowCastingEnabled())
|
||||
continue;
|
||||
|
||||
NzVector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
|
||||
Nz::Vector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
|
||||
|
||||
switch (lightComponent.GetLightType())
|
||||
{
|
||||
case nzLightType_Directional:
|
||||
case Nz::LightType_Directional:
|
||||
NazaraInternalError("Directional lights included in point/spot light list");
|
||||
break;
|
||||
|
||||
case nzLightType_Point:
|
||||
case Nz::LightType_Point:
|
||||
{
|
||||
static NzQuaternionf rotations[6] =
|
||||
static Nz::Quaternionf rotations[6] =
|
||||
{
|
||||
NzQuaternionf::RotationBetween(NzVector3f::Forward(), NzVector3f::UnitX()), // nzCubemapFace_PositiveX
|
||||
NzQuaternionf::RotationBetween(NzVector3f::Forward(), -NzVector3f::UnitX()), // nzCubemapFace_NegativeX
|
||||
NzQuaternionf::RotationBetween(NzVector3f::Forward(), -NzVector3f::UnitY()), // nzCubemapFace_PositiveY
|
||||
NzQuaternionf::RotationBetween(NzVector3f::Forward(), NzVector3f::UnitY()), // nzCubemapFace_NegativeY
|
||||
NzQuaternionf::RotationBetween(NzVector3f::Forward(), -NzVector3f::UnitZ()), // nzCubemapFace_PositiveZ
|
||||
NzQuaternionf::RotationBetween(NzVector3f::Forward(), NzVector3f::UnitZ()) // nzCubemapFace_NegativeZ
|
||||
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitX()), // nzCubemapFace_PositiveX
|
||||
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitX()), // nzCubemapFace_NegativeX
|
||||
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitY()), // nzCubemapFace_PositiveY
|
||||
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitY()), // nzCubemapFace_NegativeY
|
||||
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitZ()), // nzCubemapFace_PositiveZ
|
||||
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitZ()) // nzCubemapFace_NegativeZ
|
||||
};
|
||||
|
||||
for (unsigned int face = 0; face < 6; ++face)
|
||||
{
|
||||
m_shadowRT.AttachTexture(nzAttachmentPoint_Depth, 0, lightComponent.GetShadowMap(), face);
|
||||
NzRenderer::SetTarget(&m_shadowRT);
|
||||
NzRenderer::SetViewport(NzRecti(0, 0, shadowMapSize.x, shadowMapSize.y));
|
||||
m_shadowRT.AttachTexture(Nz::AttachmentPoint_Depth, 0, lightComponent.GetShadowMap(), face);
|
||||
Nz::Renderer::SetTarget(&m_shadowRT);
|
||||
Nz::Renderer::SetViewport(Nz::Recti(0, 0, shadowMapSize.x, shadowMapSize.y));
|
||||
|
||||
///TODO: Cache the matrices in the light?
|
||||
NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Perspective(NzFromDegrees(90.f), 1.f, 0.1f, lightComponent.GetRadius()));
|
||||
NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::ViewMatrix(lightNode.GetPosition(), rotations[face]));
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, Nz::Matrix4f::Perspective(Nz::FromDegrees(90.f), 1.f, 0.1f, lightComponent.GetRadius()));
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_View, Nz::Matrix4f::ViewMatrix(lightNode.GetPosition(), rotations[face]));
|
||||
|
||||
NzAbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
|
||||
Nz::AbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
|
||||
renderQueue->Clear();
|
||||
|
||||
///TODO: Culling
|
||||
|
|
@ -236,16 +236,17 @@ namespace Ndk
|
|||
break;
|
||||
}
|
||||
|
||||
case nzLightType_Spot:
|
||||
m_shadowRT.AttachTexture(nzAttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
|
||||
NzRenderer::SetTarget(&m_shadowRT);
|
||||
NzRenderer::SetViewport(NzRecti(0, 0, shadowMapSize.x, shadowMapSize.y));
|
||||
case Nz::LightType_Spot:
|
||||
{
|
||||
m_shadowRT.AttachTexture(Nz::AttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
|
||||
Nz::Renderer::SetTarget(&m_shadowRT);
|
||||
Nz::Renderer::SetViewport(Nz::Recti(0, 0, shadowMapSize.x, shadowMapSize.y));
|
||||
|
||||
///TODO: Cache the matrices in the light?
|
||||
NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Perspective(lightComponent.GetOuterAngle()*2.f, 1.f, 0.1f, lightComponent.GetRadius()));
|
||||
NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::ViewMatrix(lightNode.GetPosition(), lightNode.GetRotation()));
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, Nz::Matrix4f::Perspective(lightComponent.GetOuterAngle()*2.f, 1.f, 0.1f, lightComponent.GetRadius()));
|
||||
Nz::Renderer::SetMatrix(Nz::MatrixType_View, Nz::Matrix4f::ViewMatrix(lightNode.GetPosition(), lightNode.GetRotation()));
|
||||
|
||||
NzAbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
|
||||
Nz::AbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
|
||||
renderQueue->Clear();
|
||||
|
||||
///TODO: Culling
|
||||
|
|
@ -262,6 +263,7 @@ namespace Ndk
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SystemIndex RenderSystem::systemIndex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ namespace Ndk
|
|||
{
|
||||
for (auto& system : m_systems)
|
||||
{
|
||||
// Ignore non-existent systems
|
||||
if (!system)
|
||||
continue;
|
||||
|
||||
// L'entité est-elle enregistrée comme faisant partie du système ?
|
||||
bool partOfSystem = system->HasEntity(entity);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ function NazaraBuild:Execute()
|
|||
end
|
||||
|
||||
if (self.Actions[_ACTION] == nil) then
|
||||
local makeLibDir = os.is("windows") and "mingw" or "gmake"
|
||||
|
||||
if (#self.OrderedExtLibs > 0) then
|
||||
solution("NazaraExtlibs")
|
||||
platforms({"x32", "x64"})
|
||||
|
|
@ -28,12 +30,12 @@ function NazaraBuild:Execute()
|
|||
libdirs("../extlibs/lib/common/x64")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||
libdirs("../extlibs/lib/mingw/x86")
|
||||
targetdir("../extlibs/lib/mingw/x86")
|
||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||
targetdir("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x64"})
|
||||
libdirs("../extlibs/lib/mingw/x64")
|
||||
targetdir("../extlibs/lib/mingw/x64")
|
||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
|
||||
targetdir("../extlibs/lib/" .. makeLibDir .. "/x64")
|
||||
|
||||
configuration("vs*")
|
||||
buildoptions("/MP")
|
||||
|
|
@ -71,7 +73,7 @@ function NazaraBuild:Execute()
|
|||
targetsuffix("-s")
|
||||
|
||||
configuration("codeblocks or codelite or gmake or xcode3 or xcode4")
|
||||
buildoptions("-std=c++14")
|
||||
buildoptions({"-fPIC", "-std=c++14"})
|
||||
|
||||
for k, libTable in ipairs(self.OrderedExtLibs) do
|
||||
project(libTable.Name)
|
||||
|
|
@ -171,14 +173,14 @@ function NazaraBuild:Execute()
|
|||
libdirs("../extlibs/lib/common/x64")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||
libdirs("../extlibs/lib/mingw/x86")
|
||||
libdirs("../lib/mingw/x86")
|
||||
targetdir("../lib/mingw/x86")
|
||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||
libdirs("../lib/" .. makeLibDir .. "/x86")
|
||||
targetdir("../lib/" .. makeLibDir .. "/x86")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x64"})
|
||||
libdirs("../extlibs/lib/mingw/x64")
|
||||
libdirs("../lib/mingw/x64")
|
||||
targetdir("../lib/mingw/x64")
|
||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
|
||||
libdirs("../lib/" .. makeLibDir .. "/x64")
|
||||
targetdir("../lib/" .. makeLibDir .. "/x64")
|
||||
|
||||
configuration({"vs*", "x32"})
|
||||
libdirs("../extlibs/lib/msvc/x86")
|
||||
|
|
@ -268,17 +270,17 @@ function NazaraBuild:Execute()
|
|||
libdirs("../extlibs/lib/common/x64")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||
libdirs("../extlibs/lib/mingw/x86")
|
||||
libdirs("../lib/mingw/x86")
|
||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||
libdirs("../lib/" .. makeLibDir .. "/x86")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/mingw/x86")
|
||||
targetdir("../lib/" .. makeLibDir .. "/x86")
|
||||
end
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x64"})
|
||||
libdirs("../extlibs/lib/mingw/x64")
|
||||
libdirs("../lib/mingw/x64")
|
||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
|
||||
libdirs("../lib/" .. makeLibDir .. "/x64")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/mingw/x64")
|
||||
targetdir("../lib/" .. makeLibDir .. "/x64")
|
||||
end
|
||||
|
||||
configuration({"vs*", "x32"})
|
||||
|
|
@ -379,10 +381,10 @@ function NazaraBuild:Execute()
|
|||
libdirs("../extlibs/lib/common/x64")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||
libdirs("../lib/mingw/x86")
|
||||
libdirs("../lib/" .. makeLibDir .. "/x86")
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x64"})
|
||||
libdirs("../lib/mingw/x64")
|
||||
libdirs("../lib/" .. makeLibDir .. "/x64")
|
||||
|
||||
configuration({"vs*", "x32"})
|
||||
libdirs("../lib/msvc/x86")
|
||||
|
|
|
|||
|
|
@ -15,3 +15,8 @@ MODULE.OsFiles.Posix = {
|
|||
"../src/Nazara/Core/Posix/**.hpp",
|
||||
"../src/Nazara/Core/Posix/**.cpp"
|
||||
}
|
||||
|
||||
MODULE.OsLibraries.Posix = {
|
||||
"dl",
|
||||
"pthread"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
MODULE.Name = "Network"
|
||||
|
||||
MODULE.Libraries = {
|
||||
"NazaraCore"
|
||||
}
|
||||
|
||||
MODULE.OsFiles.Windows = {
|
||||
"../src/Nazara/Network/Win32/**.hpp",
|
||||
"../src/Nazara/Network/Win32/**.cpp"
|
||||
}
|
||||
|
||||
MODULE.OsFiles.Posix = {
|
||||
"../src/Nazara/Network/Posix/**.hpp",
|
||||
"../src/Nazara/Network/Posix/**.cpp"
|
||||
}
|
||||
|
||||
MODULE.OsLibraries.Windows = {
|
||||
"ws2_32"
|
||||
}
|
||||
|
|
@ -24,3 +24,8 @@ MODULE.OsLibraries.Windows = {
|
|||
"opengl32",
|
||||
"winmm"
|
||||
}
|
||||
|
||||
MODULE.OsLibraries.Posix = {
|
||||
"GL",
|
||||
"X11"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,3 +20,13 @@ MODULE.OsLibraries.Windows = {
|
|||
"gdi32"
|
||||
}
|
||||
|
||||
MODULE.OsLibraries.Posix = {
|
||||
"X11",
|
||||
"xcb",
|
||||
"xcb-cursor",
|
||||
"xcb-ewmh",
|
||||
"xcb-icccm",
|
||||
"xcb-keysyms",
|
||||
"xcb-randr"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
int main()
|
||||
{
|
||||
// NzKeyboard ne nécessite pas l'initialisation du module Utilitaire
|
||||
NzInitializer<NzAudio> audio;
|
||||
Nz::Initializer<Nz::Audio> audio;
|
||||
if (!audio)
|
||||
{
|
||||
std::cout << "Failed to initialize audio module" << std::endl;
|
||||
|
|
@ -26,7 +26,7 @@ int main()
|
|||
return 1;
|
||||
}
|
||||
|
||||
NzSound sound;
|
||||
Nz::Sound sound;
|
||||
if (!sound.LoadFromFile("resources/siren.wav"))
|
||||
{
|
||||
std::cout << "Failed to load sound" << std::endl;
|
||||
|
|
@ -44,32 +44,32 @@ int main()
|
|||
sound.EnableLooping(true);
|
||||
|
||||
// La source du son se situe vers la gauche (Et un peu en avant)
|
||||
sound.SetPosition(NzVector3f::Left()*50.f + NzVector3f::Forward()*5.f);
|
||||
sound.SetPosition(Nz::Vector3f::Left()*50.f + Nz::Vector3f::Forward()*5.f);
|
||||
|
||||
// Et possède une vitesse de 10 par seconde vers la droite
|
||||
sound.SetVelocity(NzVector3f::Left()*-10.f);
|
||||
sound.SetVelocity(Nz::Vector3f::Left()*-10.f);
|
||||
|
||||
// On joue le son
|
||||
sound.Play();
|
||||
|
||||
// La boucle du programme (Pour déplacer le son)
|
||||
NzClock clock;
|
||||
while (sound.GetStatus() == nzSoundStatus_Playing)
|
||||
Nz::Clock clock;
|
||||
while (sound.GetStatus() == Nz::SoundStatus_Playing)
|
||||
{
|
||||
// Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement
|
||||
int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS
|
||||
|
||||
if (sleepTime > 0)
|
||||
NzThread::Sleep(sleepTime);
|
||||
Nz::Thread::Sleep(sleepTime);
|
||||
|
||||
// On bouge la source du son en fonction du temps depuis chaque mise à jour
|
||||
NzVector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds();
|
||||
Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds();
|
||||
sound.SetPosition(pos);
|
||||
|
||||
std::cout << "Sound position: " << pos << std::endl;
|
||||
|
||||
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
|
||||
if (pos.x > NzVector3f::Left().x*-50.f || NzKeyboard::IsKeyPressed(NzKeyboard::Escape))
|
||||
if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Escape))
|
||||
sound.Stop(); // On arrête le son (Stoppant également la boucle)
|
||||
|
||||
clock.Restart();
|
||||
|
|
|
|||
|
|
@ -10,5 +10,6 @@ EXAMPLE.Libraries = {
|
|||
"NazaraCore",
|
||||
"NazaraGraphics",
|
||||
"NazaraRenderer",
|
||||
"NazaraUtility"
|
||||
"NazaraUtility",
|
||||
"NazaraSDK"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,18 +15,25 @@
|
|||
#include <Nazara/Graphics.hpp> // Module graphique
|
||||
#include <Nazara/Renderer.hpp> // Module de rendu
|
||||
#include <Nazara/Utility.hpp> // Module utilitaire
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Sdk.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <iostream>
|
||||
|
||||
// Petite fonction permettant de rendre le déplacement de la caméra moins ridige
|
||||
NzVector3f DampedString(const NzVector3f& currentPos, const NzVector3f& targetPos, float frametime, float springStrength = 3.f);
|
||||
Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& targetPos, float frametime, float springStrength = 3.f);
|
||||
|
||||
int main()
|
||||
{
|
||||
// Pour commencer, nous initialisons le module Graphique, celui-ci va provoquer l'initialisation (dans l'ordre),
|
||||
// du noyau (Core), Utility, Renderer.
|
||||
// Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur,
|
||||
// les composants, systèmes, etc.
|
||||
// NzInitializer est une classe RAII appelant Initialize dans son constructeur et Uninitialize dans son destructeur.
|
||||
// Autrement dit, une fois ceci fait nous n'avons plus à nous soucier de la libération du moteur.
|
||||
NzInitializer<NzGraphics> nazara;
|
||||
Nz::Initializer<Ndk::Sdk> nazara;
|
||||
if (!nazara)
|
||||
{
|
||||
// Une erreur s'est produite dans l'initialisation d'un des modules
|
||||
|
|
@ -36,17 +43,16 @@ int main()
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Nazara étant initialisé, nous pouvons créer la scène
|
||||
// Une scène représente tout ce qui est visible par une ou plusieurs caméras.
|
||||
// La plupart du temps vous n'aurez pas besoin de plus d'une scène, mais cela peut se révéler utile pour mieux
|
||||
// organiser et optimiser le rendu.
|
||||
// Par exemple, une pièce contenant une télévision, laquelle affichant des images provenant d'une Camera
|
||||
// Le rendu sera alors plus efficace en créant deux scènes, une pour la pièce et l'autre pour les images de la télé.
|
||||
// Cela diminuera le nombre de SceneNode à gérer pour chaque scène, et vous permettra même de ne pas afficher la scène
|
||||
// affichée dans la télé si cette dernière n'est pas visible dans la première scène.
|
||||
NzScene scene;
|
||||
// Nazara étant initialisé, nous pouvons créer le monde pour contenir notre scène.
|
||||
// Dans un ECS, le monde représente bien ce que son nom indique, c'est l'ensemble de ce qui existe au niveau de l'application.
|
||||
// Il contient les systèmes et les entités, ces dernières contiennent les composants.
|
||||
// Il est possible d'utiliser plusieurs mondes au sein d'une même application, par exemple pour gérer un mélange de 2D et de 3D,
|
||||
// mais nous verrons cela dans un prochain exemple.
|
||||
Ndk::World world;
|
||||
|
||||
// La première chose que nous faisons est d'ajouter un background (fond) à la scène.
|
||||
// Nous pouvons maintenant ajouter des systèmes, mais dans cet exemple nous nous contenterons de ceux de base.
|
||||
|
||||
// La première chose que nous faisons est d'ajouter un background (fond) à notre scène.
|
||||
// Il en existe plusieurs types, le moteur inclut pour l'instant trois d'entre eux:
|
||||
// -ColorBackground: Une couleur unie en fond
|
||||
// -SkyboxBackground: Une skybox en fond, un cube à six faces rendu autour de la caméra (En perdant la notion de distance)
|
||||
|
|
@ -56,53 +62,59 @@ int main()
|
|||
// Pour commencer il faut charger une texture de type cubemap, certaines images sont assemblées de cette façon,
|
||||
// comme celle que nous allons utiliser.
|
||||
// En réalité les textures "cubemap" regroupent six faces en une, pour faciliter leur utilisation.
|
||||
NzTexture* texture = new NzTexture;
|
||||
|
||||
// Nous créons une nouvelle texture et prenons une référence sur celle-ci (à la manière des pointeurs intelligents)
|
||||
Nz::TextureRef texture = Nz::Texture::New();
|
||||
if (texture->LoadCubemapFromFile("resources/skybox-space.png"))
|
||||
{
|
||||
// Si la création du cubemap a fonctionné
|
||||
|
||||
// Nous indiquons que la texture est "non-persistente", autrement dit elle sera libérée automatiquement par le moteur
|
||||
// à l'instant précis où elle ne sera plus utilisée, dans ce cas-ci, ce sera à la libération de l'objet skybox,
|
||||
// ceci arrivant lorsqu'un autre background est affecté à la scène, ou lorsque la scène sera libérée
|
||||
texture->SetPersistent(false);
|
||||
// Nous créons alors le background à partir de notre texture (celui-ci va référencer notre texture, notre pointeur ne sert alors plus à rien).
|
||||
Nz::SkyboxBackgroundRef skybox = Nz::SkyboxBackground::New(std::move(texture));
|
||||
|
||||
// Nous créons le background en lui affectant la texture
|
||||
NzSkyboxBackground* background = new NzSkyboxBackground(texture);
|
||||
// Accédons maintenant au système de rendu faisant partie du monde
|
||||
Ndk::RenderSystem& renderSystem = world.GetSystem<Ndk::RenderSystem>(); // Une assertion valide la précondition "le système doit faire partie du monde"
|
||||
|
||||
// Nous pouvons en profiter pour paramétrer le background.
|
||||
// Cependant, nous n'avons rien de spécial à faire ici, nous pouvons donc l'envoyer à la scène.
|
||||
scene.SetBackground(background);
|
||||
// Nous assignons ensuite notre skybox comme "fond par défaut" du système
|
||||
// La notion "par défaut" existe parce qu'une caméra pourrait utiliser son propre fond lors du rendu,
|
||||
// le fond par défaut est utilisé lorsque la caméra n'a pas de fond propre assigné
|
||||
renderSystem.SetDefaultBackground(std::move(skybox));
|
||||
|
||||
// Comme indiqué plus haut, la scène s'occupera automatiquement de la libération de notre background
|
||||
// Notre skybox est maintenant référencée par le système, lui-même appartenant au monde, aucune libération explicite n'est nécessaire
|
||||
}
|
||||
else
|
||||
{
|
||||
delete texture; // Le chargement a échoué, nous libérons la texture
|
||||
// Le chargement a échoué
|
||||
std::cout << "Failed to load skybox" << std::endl;
|
||||
}
|
||||
|
||||
// Ensuite, nous allons rajouter un modèle à notre scène.
|
||||
|
||||
// Les modèles représentent, globalement, tout ce qui est visible en trois dimensions.
|
||||
// Nous choisirons ici un vaisseau spatial (Quoi de mieux pour une scène spatiale ?)
|
||||
NzModel* spaceship = scene.CreateNode<NzModel>(); // Création depuis la scène
|
||||
|
||||
// Une structure permettant de paramétrer le chargement des modèles
|
||||
NzModelParameters params;
|
||||
// Encore une fois, nous récupérons une référence plutôt que l'objet lui-même (cela va être très utile par la suite)
|
||||
Nz::ModelRef spaceshipModel = Nz::Model::New();
|
||||
|
||||
// Le format OBJ ne précise aucune échelle pour ses données, contrairement à Nazara (une unité = un mètre).
|
||||
// Comme le vaisseau est très grand (Des centaines de mètres de long), nous allons le rendre plus petit
|
||||
// pour les besoins de la démo.
|
||||
// Nous allons charger notre modèle depuis un fichier, mais nous pouvons ajuster le modèle lors du chargement via
|
||||
// une structure permettant de paramétrer le chargement des modèles
|
||||
Nz::ModelParameters params;
|
||||
|
||||
// Le format OBJ ne précise aucune échelle pour ses données, contrairement à Nazara (une unité = un mètre en 3D).
|
||||
// Comme le vaisseau est très grand (Des centaines de mètres de long), nous allons le rendre plus petit pour les besoins de la démo.
|
||||
// Ce paramètre sert à indiquer la mise à l'échelle désirée lors du chargement du modèle.
|
||||
params.mesh.scale.Set(0.01f); // Un centième de la taille originelle
|
||||
|
||||
// Les UVs de ce fichier sont retournées (repère OpenGL, origine coin bas-gauche) par rapport à ce que le moteur attend
|
||||
// Nous devons dire au moteur de les retourner lors du chargement
|
||||
// Les UVs de ce fichier sont retournées (repère OpenGL, origine coin bas-gauche) par rapport à ce que le moteur attend (haut-gauche)
|
||||
// Nous devons donc indiquer au moteur de les retourner lors du chargement
|
||||
params.mesh.flipUVs = true;
|
||||
|
||||
// Nazara va par défaut optimiser les modèles pour un rendu plus rapide, cela peut prendre du temps et n'est pas nécessaire ici
|
||||
params.mesh.optimizeIndexBuffers = false;
|
||||
|
||||
// On charge ensuite le modèle depuis son fichier
|
||||
// Le moteur va charger le fichier et essayer de retrouver les fichiers associés (comme les matériaux, textures, ...)
|
||||
if (!spaceship->LoadFromFile("resources/Spaceship/spaceship.obj", params))
|
||||
if (!spaceshipModel->LoadFromFile("resources/Spaceship/spaceship.obj", params))
|
||||
{
|
||||
// Si le chargement a échoué (fichier inexistant/invalide), il ne sert à rien de continuer
|
||||
std::cout << "Failed to load spaceship" << std::endl;
|
||||
std::getchar();
|
||||
|
||||
|
|
@ -111,15 +123,18 @@ int main()
|
|||
|
||||
// Nous voulons afficher quelques statistiques relatives au modèle, comme le nombre de sommets et de triangles
|
||||
// Pour cela, nous devons accéder au mesh (maillage 3D)
|
||||
NzMesh* mesh = spaceship->GetMesh();
|
||||
|
||||
// Note: Si nous voulions stocker le mesh pour nous en servir après, nous devrions alors récupérer une référence pour nous assurer
|
||||
// qu'il ne sera pas supprimé tant que nous l'utilisons, mais ici nous faisons un accès direct et ne nous servons plus du pointeur par la suite
|
||||
// Il est donc acceptable d'utiliser un pointeur nu ici.
|
||||
Nz::Mesh* mesh = spaceshipModel->GetMesh();
|
||||
std::cout << mesh->GetVertexCount() << " sommets" << std::endl;
|
||||
std::cout << mesh->GetTriangleCount() << " triangles" << std::endl;
|
||||
|
||||
// En revanche, le format OBJ ne précise pas l'utilisation d'une normal map, nous devons donc la charger manuellement
|
||||
// Pour commencer on récupère le matériau du mesh, celui-ci en possède plusieurs mais celui qui nous intéresse,
|
||||
// celui de la coque, est le second (Cela est bien entendu lié au modèle en lui-même)
|
||||
NzMaterial* material = spaceship->GetMaterial(1);
|
||||
Nz::Material* material = spaceshipModel->GetMaterial(1); // Encore une fois nous ne faisons qu'un accès direct.
|
||||
|
||||
// On lui indique ensuite le chemin vers la normal map
|
||||
if (!material->SetNormalMap("resources/Spaceship/Texture/normal.png"))
|
||||
|
|
@ -129,27 +144,58 @@ int main()
|
|||
std::cout << "Failed to load normal map" << std::endl;
|
||||
}
|
||||
|
||||
// Nous avons besoin également d'une caméra, pour des raisons évidentes, celle-ci sera à l'écart du modèle
|
||||
// Bien, nous avons un modèle valide, mais celui-ci ne consiste qu'en des informations de rendu, de matériaux et de textures.
|
||||
// Commençons donc par créer une entité vide, cela se fait en demandant au monde de générer une nouvelle entité.
|
||||
Ndk::EntityHandle spaceship = world.CreateEntity();
|
||||
|
||||
// Note: Nous ne récupérons pas l'entité directement mais un "handle" vers elle, ce dernier est un pointeur intelligent non-propriétaire.
|
||||
// Pour des raisons techniques, le pointeur de l'entité peut venir à changer, ou l'entité être simplement détruite pour n'importe quelle raison.
|
||||
// Le Handle nous permet de maintenir un pointeur valide vers notre entité, et invalidé automatiquement à sa mort.
|
||||
|
||||
// Nous avons désormais une entité, mais celle-ci ne contient rien et n'a d'autre propriété qu'un identifiant
|
||||
// Nous devons donc lui rajouter les composants que nous voulons.
|
||||
|
||||
// Un NodeComponent donne à notre entité une position, rotation, échelle, et nous permet de l'attacher à d'autres entités (ce que nous ne ferons pas ici).
|
||||
// Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient,
|
||||
// nous n'avons pas besoin d'agir sur le composant créé.
|
||||
spaceship->AddComponent<Ndk::NodeComponent>();
|
||||
|
||||
// Bien, notre entité nouvellement créé dispose maintenant d'une position dans la scène, mais est toujours invisible
|
||||
// Nous lui ajoutons donc un GraphicsComponent
|
||||
Ndk::GraphicsComponent& spaceshipGraphics = spaceship->AddComponent<Ndk::GraphicsComponent>();
|
||||
|
||||
// Ce composant sert de point d'attache pour tous les renderables instanciés (tels que les modèles, les sprites, le texte, etc.)
|
||||
// Cela signifie également qu'un modèle peut être attaché à autant d'entités que nécessaire.
|
||||
// Note: Afin de maximiser les performances, essayez d'avoir le moins de renderables instanciés/matériaux et autres ressources possible
|
||||
// le moteur fonctionne selon le batching et regroupera par exemple tous les modèles identiques ensembles lors du rendu.
|
||||
spaceshipGraphics.Attach(spaceshipModel);
|
||||
|
||||
// Nous avons besoin également d'une caméra pour servir de point de vue à notre scène, celle-ci sera à l'écart du modèle
|
||||
// regardant dans sa direction.
|
||||
|
||||
// On conserve la rotation à part via des angles d'eulers pour la caméra free-fly
|
||||
NzEulerAnglesf camAngles(0.f, -20.f, 0.f);
|
||||
Nz::EulerAnglesf camAngles(0.f, -20.f, 0.f);
|
||||
|
||||
NzCamera camera;
|
||||
camera.SetPosition(0.f, 0.25f, 2.f); // On place la caméra à l'écart
|
||||
camera.SetRotation(camAngles);
|
||||
// Nous créons donc une seconde entité
|
||||
// Note: La création d'entité est une opération légère au sein du moteur, mais plus vous aurez d'entités et plus le processeur devra travailler.
|
||||
Ndk::EntityHandle camera = world.CreateEntity();
|
||||
|
||||
// Notre caméra a elle aussi besoin d'être positionnée dans la scène
|
||||
Ndk::NodeComponent& cameraNode = camera->AddComponent<Ndk::NodeComponent>();
|
||||
cameraNode.SetPosition(0.f, 0.25f, 2.f); // On place la caméra à l'écart
|
||||
cameraNode.SetRotation(camAngles);
|
||||
|
||||
// Et dispose d'un composant pour chaque point de vue de la scène, le CameraComponent
|
||||
Ndk::CameraComponent& cameraComp = camera->AddComponent<Ndk::CameraComponent>();
|
||||
|
||||
// Et on n'oublie pas de définir les plans délimitant le champs de vision
|
||||
// (Seul ce qui se trouvera entre les deux plans sera rendu)
|
||||
|
||||
// La distance entre l'oeil et le plan éloigné
|
||||
camera.SetZFar(5000.f);
|
||||
cameraComp.SetZFar(5000.f);
|
||||
|
||||
// La distance entre l'oeil et le plan rapproché (0 est une valeur interdite car la division par zéro l'est également)
|
||||
camera.SetZNear(0.1f);
|
||||
|
||||
// On indique à la scène que le viewer (Le point de vue) sera la caméra
|
||||
scene.SetViewer(camera);
|
||||
cameraComp.SetZNear(0.1f);
|
||||
|
||||
// Attention que le ratio entre les deux (zFar/zNear) doit rester raisonnable, dans le cas contraire vous risquez un phénomène
|
||||
// de "Z-Fighting" (Impossibilité de déduire quelle surface devrait apparaître en premier) sur les surfaces éloignées.
|
||||
|
|
@ -160,40 +206,47 @@ int main()
|
|||
// -PointLight: Lumière située à un endroit précis, envoyant de la lumière finie dans toutes les directions
|
||||
// -SpotLight: Lumière située à un endroit précis, envoyant de la lumière vers un endroit donné, avec un angle de diffusion
|
||||
|
||||
// Nous créons une lumière directionnelle pour représenter la nébuleuse de notre skybox
|
||||
NzLight* nebulaLight = scene.CreateNode<NzLight>(nzLightType_Directional);
|
||||
// Nous allons créer une lumière directionnelle pour représenter la nébuleuse de notre skybox
|
||||
// Encore une fois, nous créons notre entité
|
||||
Ndk::EntityHandle nebulaLight = world.CreateEntity();
|
||||
|
||||
// Lui ajoutons une position dans la scène
|
||||
Ndk::NodeComponent& nebulaLightNode = nebulaLight->AddComponent<Ndk::NodeComponent>();
|
||||
|
||||
// Et ensuite le composant principal, le LightComponent
|
||||
Ndk::LightComponent& nebulaLightComp = nebulaLight->AddComponent<Ndk::LightComponent>(Nz::LightType_Directional);
|
||||
|
||||
// Il nous faut ensuite configurer la lumière
|
||||
// Pour commencer, sa couleur, la nébuleuse étant d'une couleur jaune, j'ai choisi ces valeurs
|
||||
nebulaLight->SetColor(NzColor(255, 182, 90));
|
||||
nebulaLightComp.SetColor(Nz::Color(255, 182, 90));
|
||||
|
||||
// Nous appliquons ensuite une rotation de sorte que la lumière dans la même direction que la nébuleuse
|
||||
nebulaLight->SetRotation(NzEulerAnglesf(0.f, 102.f, 0.f));
|
||||
nebulaLightNode.SetRotation(Nz::EulerAnglesf(0.f, 102.f, 0.f));
|
||||
|
||||
// Nous allons maintenant créer la fenêtre, dans laquelle nous ferons nos rendus
|
||||
// Celle-ci demande des paramètres plus complexes
|
||||
|
||||
// Pour commencer le mode vidéo, celui-ci va définir la taille de la zone de rendu et le nombre de bits par pixels
|
||||
NzVideoMode mode = NzVideoMode::GetDesktopMode(); // Nous récupérons le mode vidéo du bureau
|
||||
Nz::VideoMode mode = Nz::VideoMode::GetDesktopMode(); // Nous récupérons le mode vidéo du bureau
|
||||
|
||||
// Nous allons prendre les trois quarts de la résolution du bureau pour notre fenêtre
|
||||
mode.width *= 3.f/4.f;
|
||||
mode.height *= 3.f/4.f;
|
||||
mode.width = 3 * mode.width / 4;
|
||||
mode.height = 3 * mode.height / 4;
|
||||
|
||||
// Maintenant le titre, rien de plus simple...
|
||||
NzString windowTitle = "Nazara Demo - First scene";
|
||||
Nz::String windowTitle = "Nazara Demo - First scene";
|
||||
|
||||
// Ensuite, le "style" de la fenêtre, possède-t-elle des bordures, peut-on cliquer sur la croix de fermeture,
|
||||
// peut-on la redimensionner, ...
|
||||
nzWindowStyleFlags style = nzWindowStyle_Default; // Nous prenons le style par défaut, autorisant tout ce que je viens de citer
|
||||
Nz::WindowStyleFlags style = Nz::WindowStyle_Default; // Nous prenons le style par défaut, autorisant tout ce que je viens de citer
|
||||
|
||||
// Ensuite, les paramètres du contexte de rendu
|
||||
// On peut configurer le niveau d'antialiasing, le nombre de bits du depth buffer et le nombre de bits du stencil buffer
|
||||
// Nous désirons avoir un peu d'antialiasing (4x), les valeurs par défaut pour le reste nous conviendrons très bien
|
||||
NzRenderTargetParameters parameters;
|
||||
Nz::RenderTargetParameters parameters;
|
||||
parameters.antialiasingLevel = 4;
|
||||
|
||||
NzRenderWindow window(mode, windowTitle, style, parameters);
|
||||
Nz::RenderWindow window(mode, windowTitle, style, parameters);
|
||||
if (!window.IsValid())
|
||||
{
|
||||
std::cout << "Failed to create render window" << std::endl;
|
||||
|
|
@ -203,62 +256,63 @@ int main()
|
|||
}
|
||||
|
||||
// On fait disparaître le curseur de la souris
|
||||
window.SetCursor(nzWindowCursor_None);
|
||||
window.SetCursor(Nz::WindowCursor_None);
|
||||
|
||||
// On lie la caméra à la fenêtre
|
||||
camera.SetTarget(window);
|
||||
cameraComp.SetTarget(&window);
|
||||
|
||||
// Et on créé deux horloges pour gérer le temps
|
||||
NzClock secondClock, updateClock;
|
||||
Nz::Clock secondClock, updateClock;
|
||||
Nz::UInt64 updateAccumulator = 0;
|
||||
|
||||
// Ainsi qu'un compteur de FPS improvisé
|
||||
unsigned int fps = 0;
|
||||
|
||||
// Quelques variables de plus pour notre caméra
|
||||
bool smoothMovement = true;
|
||||
NzVector3f targetPos = camera.GetPosition();
|
||||
Nz::Vector3f targetPos = cameraNode.GetPosition();
|
||||
|
||||
// Début de la boucle de rendu du programme
|
||||
while (window.IsOpen())
|
||||
{
|
||||
// Ensuite nous allons traiter les évènements (Étape indispensable pour la fenêtre)
|
||||
NzEvent event;
|
||||
Nz::WindowEvent event;
|
||||
while (window.PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case nzEventType_MouseMoved: // La souris a bougé
|
||||
case Nz::WindowEventType_MouseMoved: // La souris a bougé
|
||||
{
|
||||
// Gestion de la caméra free-fly (Rotation)
|
||||
float sensitivity = 0.3f; // Sensibilité de la souris
|
||||
|
||||
// On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris
|
||||
camAngles.yaw = NzNormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity);
|
||||
camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity);
|
||||
|
||||
// Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles
|
||||
camAngles.pitch = NzClamp(camAngles.pitch - event.mouseMove.deltaY*sensitivity, -89.f, 89.f);
|
||||
camAngles.pitch = Nz::Clamp(camAngles.pitch - event.mouseMove.deltaY*sensitivity, -89.f, 89.f);
|
||||
|
||||
// On applique les angles d'Euler à notre caméra
|
||||
camera.SetRotation(camAngles);
|
||||
cameraNode.SetRotation(camAngles);
|
||||
|
||||
// Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre
|
||||
// Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved
|
||||
NzMouse::SetPosition(window.GetWidth()/2, window.GetHeight()/2, window);
|
||||
Nz::Mouse::SetPosition(window.GetWidth()/2, window.GetHeight()/2, window);
|
||||
break;
|
||||
}
|
||||
|
||||
case nzEventType_Quit: // L'utilisateur a cliqué sur la croix, ou l'OS veut terminer notre programme
|
||||
case Nz::WindowEventType_Quit: // L'utilisateur a cliqué sur la croix, ou l'OS veut terminer notre programme
|
||||
window.Close(); // On demande la fermeture de la fenêtre (Qui aura lieu au prochain tour de boucle)
|
||||
break;
|
||||
|
||||
case nzEventType_KeyPressed: // Une touche a été pressée !
|
||||
if (event.key.code == NzKeyboard::Key::Escape)
|
||||
case Nz::WindowEventType_KeyPressed: // Une touche a été pressée !
|
||||
if (event.key.code == Nz::Keyboard::Key::Escape)
|
||||
window.Close();
|
||||
else if (event.key.code == NzKeyboard::F1)
|
||||
else if (event.key.code == Nz::Keyboard::F1)
|
||||
{
|
||||
if (smoothMovement)
|
||||
{
|
||||
targetPos = camera.GetPosition();
|
||||
targetPos = cameraNode.GetPosition();
|
||||
smoothMovement = false;
|
||||
}
|
||||
else
|
||||
|
|
@ -271,68 +325,63 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
Nz::UInt64 elapsedUS = updateClock.GetMicroseconds();
|
||||
// On relance l'horloge
|
||||
updateClock.Restart();
|
||||
|
||||
// Mise à jour (Caméra)
|
||||
if (updateClock.GetMilliseconds() >= 1000/60) // 60 fois par seconde
|
||||
const Nz::UInt64 updateRate = 1000000 / 60; // 60 fois par seconde
|
||||
updateAccumulator += elapsedUS;
|
||||
|
||||
if (updateAccumulator >= updateRate)
|
||||
{
|
||||
// Le temps écoulé depuis la dernière fois que ce bloc a été exécuté
|
||||
float elapsedTime = updateClock.GetSeconds();
|
||||
// Le temps écoulé en seconde depuis la dernière fois que ce bloc a été exécuté
|
||||
float elapsedTime = updateAccumulator / 1000000.f;
|
||||
std::cout << elapsedTime << std::endl;
|
||||
|
||||
// Vitesse de déplacement de la caméra
|
||||
float cameraSpeed = 3.f * elapsedTime; // Trois mètres par seconde
|
||||
|
||||
// Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::Space))
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space))
|
||||
cameraSpeed *= 2.f;
|
||||
|
||||
// Pour que nos déplacement soient liés à la rotation de la caméra, nous allons utiliser
|
||||
// les directions locales de la caméra
|
||||
|
||||
// Si la flèche du haut ou la touche Z (vive ZQSD) est pressée, on avance
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::Up) || NzKeyboard::IsKeyPressed(NzKeyboard::Z))
|
||||
targetPos += camera.GetForward() * cameraSpeed;
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z))
|
||||
targetPos += cameraNode.GetForward() * cameraSpeed;
|
||||
|
||||
// Si la flèche du bas ou la touche S est pressée, on recule
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::Down) || NzKeyboard::IsKeyPressed(NzKeyboard::S))
|
||||
targetPos += camera.GetBackward() * cameraSpeed;
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S))
|
||||
targetPos += cameraNode.GetBackward() * cameraSpeed;
|
||||
|
||||
// Etc...
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::Left) || NzKeyboard::IsKeyPressed(NzKeyboard::Q))
|
||||
targetPos += camera.GetLeft() * cameraSpeed;
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q))
|
||||
targetPos += cameraNode.GetLeft() * cameraSpeed;
|
||||
|
||||
// Etc...
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::Right) || NzKeyboard::IsKeyPressed(NzKeyboard::D))
|
||||
targetPos += camera.GetRight() * cameraSpeed;
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D))
|
||||
targetPos += cameraNode.GetRight() * cameraSpeed;
|
||||
|
||||
// Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation)
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::LShift) || NzKeyboard::IsKeyPressed(NzKeyboard::RShift))
|
||||
targetPos += NzVector3f::Up() * cameraSpeed;
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift))
|
||||
targetPos += Nz::Vector3f::Up() * cameraSpeed;
|
||||
|
||||
// Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc...
|
||||
if (NzKeyboard::IsKeyPressed(NzKeyboard::LControl) || NzKeyboard::IsKeyPressed(NzKeyboard::RControl))
|
||||
targetPos += NzVector3f::Down() * cameraSpeed;
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl))
|
||||
targetPos += Nz::Vector3f::Down() * cameraSpeed;
|
||||
|
||||
camera.SetPosition((smoothMovement) ? DampedString(camera.GetPosition(), targetPos, elapsedTime) : targetPos, nzCoordSys_Global);
|
||||
cameraNode.SetPosition((smoothMovement) ? DampedString(cameraNode.GetPosition(), targetPos, elapsedTime) : targetPos, Nz::CoordSys_Global);
|
||||
|
||||
// On relance l'horloge
|
||||
updateClock.Restart();
|
||||
updateAccumulator = 0;
|
||||
}
|
||||
|
||||
// Rendu de la scène:
|
||||
// On procède maintenant au rendu de la scène en elle-même, celui-ci se décompose en quatre étapes distinctes
|
||||
|
||||
// Pour commencer, on met à jour la scène, ceci appelle la méthode Update de tous les SceneNode enregistrés
|
||||
// pour la mise à jour globale (Scene::RegisterForUpdate)
|
||||
scene.Update();
|
||||
|
||||
// Ensuite il y a le calcul de visibilité, la scène se sert de la caméra active pour effectuer un test de visibilité
|
||||
// afin de faire une liste des SceneNode visibles (Ex: Frustum culling)
|
||||
scene.Cull();
|
||||
|
||||
// Ensuite il y a la mise à jour des SceneNode enregistrés pour la mise à jour visible (Exemple: Terrain)
|
||||
scene.UpdateVisible();
|
||||
|
||||
// Pour terminer, il y a l'affichage en lui-même, de façon organisée et optimisée (Batching)
|
||||
scene.Draw();
|
||||
// Et maintenant pour rendre la scène, il nous suffit de mettre à jour le monde en lui envoyant le temps depuis la dernière mise à jour
|
||||
// Note: La plupart des systèmes, à l'exception de celui de rendu, ont une fréquence de mise à jour fixe (modifiable)
|
||||
// Il n'est donc pas nécessaire de limiter vous-même les mises à jour du monde
|
||||
world.Update(elapsedUS / 1000000.f);
|
||||
|
||||
// Après avoir dessiné sur la fenêtre, il faut s'assurer qu'elle affiche cela
|
||||
// Cet appel ne fait rien d'autre qu'échanger les buffers de rendu (Double Buffering)
|
||||
|
|
@ -344,7 +393,7 @@ int main()
|
|||
if (secondClock.GetMilliseconds() >= 1000) // Toutes les secondes
|
||||
{
|
||||
// Et on insère ces données dans le titre de la fenêtre
|
||||
window.SetTitle(windowTitle + " - " + NzString::Number(fps) + " FPS");
|
||||
window.SetTitle(windowTitle + " - " + Nz::String::Number(fps) + " FPS");
|
||||
|
||||
/*
|
||||
Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier,
|
||||
|
|
@ -364,7 +413,7 @@ int main()
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
NzVector3f DampedString(const NzVector3f& currentPos, const NzVector3f& targetPos, float frametime, float springStrength)
|
||||
Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& targetPos, float frametime, float springStrength)
|
||||
{
|
||||
// Je ne suis pas l'auteur de cette fonction
|
||||
// Je l'ai reprise du programme "Floaty Camera Example" et adaptée au C++
|
||||
|
|
@ -372,13 +421,13 @@ NzVector3f DampedString(const NzVector3f& currentPos, const NzVector3f& targetPo
|
|||
// Tout le mérite revient à l'auteur (Qui me permettra ainsi d'améliorer les démos, voire même le moteur)
|
||||
|
||||
// calculate the displacement between the target and the current position
|
||||
NzVector3f displacement = targetPos - currentPos;
|
||||
Nz::Vector3f displacement = targetPos - currentPos;
|
||||
|
||||
// whats the distance between them?
|
||||
float displacementLength = displacement.GetLength();
|
||||
|
||||
// Stops small position fluctuations (integration errors probably - since only using euler)
|
||||
if (NzNumberEquals(displacementLength, 0.f))
|
||||
if (Nz::NumberEquals(displacementLength, 0.f))
|
||||
return currentPos;
|
||||
|
||||
float invDisplacementLength = 1.f/displacementLength;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** HardwareInfo - Récupération des caractéristiques de l'ordinateur
|
||||
** Nz::HardwareInfo - Récupération des caractéristiques de l'ordinateur
|
||||
** Prérequis: Aucun
|
||||
** Utilisation du noyau et du module de rendu
|
||||
** Présente:
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
void printCap(std::ostream& o, const NzString& cap, bool b);
|
||||
void printCap(std::ostream& o, const Nz::String& cap, bool b);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -28,68 +28,63 @@ int main()
|
|||
// Plutôt que d'initialiser le Renderer de Nazara, nous initialisons les deux classes utilisées ici
|
||||
// Elles sont compatibles avec NzInitialiser et seront donc libérées automatiquement
|
||||
// Cela permet d'avoir une initialisation plus rapide et un coût en mémoire moindre
|
||||
NzInitializer<NzHardwareInfo> hardwareInfo;
|
||||
Nz::Initializer<Nz::HardwareInfo> hardwareInfo;
|
||||
if (hardwareInfo)
|
||||
{
|
||||
// On commence par les informations sur le processeur, Nazara en récupère trois caractéristiques:
|
||||
// 1) La "brand string", qui est une chaîne de 48 caractères identifiant le processeur
|
||||
// 2) Le concepteur du processeur, accessible via une énumération (GetProcessorVendor) ou une chaîne de caractère (GetProcessorVendorName)
|
||||
// 3) Le nombre de processeurs logique, alias bien souvent le nombre de coeurs (logiques), cette valeur est renvoyée par l'OS (Le SMT multiplie donc la valeur réelle)
|
||||
oss << "Identification: " << NzHardwareInfo::GetProcessorBrandString() << std::endl;
|
||||
oss << "Concepteur: " << NzHardwareInfo::GetProcessorVendorName() << std::endl;
|
||||
oss << "Nombre de coeurs logiques: " << NzHardwareInfo::GetProcessorCount() << std::endl;
|
||||
oss << "Identification: " << Nz::HardwareInfo::GetProcessorBrandString() << std::endl;
|
||||
oss << "Concepteur: " << Nz::HardwareInfo::GetProcessorVendorName() << std::endl;
|
||||
oss << "Nombre de coeurs logiques: " << Nz::HardwareInfo::GetProcessorCount() << std::endl;
|
||||
oss << std::endl;
|
||||
|
||||
// Ensuite, Nazara récupère les capacités du processeur, dont des jeux d'extensions supplémentaires
|
||||
oss << "Rapport des capacites: " << std::endl;// Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça)
|
||||
printCap(oss, "-64bits", NzHardwareInfo::HasCapability(nzProcessorCap_x64));
|
||||
printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX));
|
||||
printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3));
|
||||
printCap(oss, "-FMA4", NzHardwareInfo::HasCapability(nzProcessorCap_FMA4));
|
||||
printCap(oss, "-MMX", NzHardwareInfo::HasCapability(nzProcessorCap_MMX));
|
||||
printCap(oss, "-SSE", NzHardwareInfo::HasCapability(nzProcessorCap_SSE));
|
||||
printCap(oss, "-SSE2", NzHardwareInfo::HasCapability(nzProcessorCap_SSE2));
|
||||
printCap(oss, "-SSE3", NzHardwareInfo::HasCapability(nzProcessorCap_SSE3));
|
||||
printCap(oss, "-SSSE3", NzHardwareInfo::HasCapability(nzProcessorCap_SSSE3));
|
||||
printCap(oss, "-SSE4.1", NzHardwareInfo::HasCapability(nzProcessorCap_SSE41));
|
||||
printCap(oss, "-SSE4.2", NzHardwareInfo::HasCapability(nzProcessorCap_SSE42));
|
||||
printCap(oss, "-SSE4.a", NzHardwareInfo::HasCapability(nzProcessorCap_SSE4a));
|
||||
printCap(oss, "-64bits", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_x64));
|
||||
printCap(oss, "-AVX", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_AVX));
|
||||
printCap(oss, "-FMA3", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_FMA3));
|
||||
printCap(oss, "-FMA4", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_FMA4));
|
||||
printCap(oss, "-MMX", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_MMX));
|
||||
printCap(oss, "-SSE", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE));
|
||||
printCap(oss, "-SSE2", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE2));
|
||||
printCap(oss, "-SSE3", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE3));
|
||||
printCap(oss, "-SSSE3", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSSE3));
|
||||
printCap(oss, "-SSE4.1", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE41));
|
||||
printCap(oss, "-SSE4.2", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE42));
|
||||
printCap(oss, "-SSE4.a", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE4a));
|
||||
}
|
||||
else
|
||||
oss << "Impossible de retrouver les informations du processeur" << std::endl;
|
||||
|
||||
oss << std::endl << "--Carte graphique--" << std::endl;
|
||||
// La classe NzOpenGL nous donne accès à des informations sur la carte graphique
|
||||
// La classe OpenGL nous donne accès à des informations sur la carte graphique
|
||||
// Cependant celle-ci n'est accessible que si le projet est compilé avec NAZARA_RENDERER_OPENGL
|
||||
// et que les répertoires d'inclusions donnent accès aux includes d'OpenGL (Cette démo utilisent ceux de Nazara)
|
||||
NzInitializer<NzOpenGL> openGL;
|
||||
Nz::Initializer<Nz::OpenGL> openGL;
|
||||
if (openGL)
|
||||
{
|
||||
// Nous récupérons ensuite la version d'OpenGL sous forme d'entier (ex: OpenGL 3.3 donnera 330)
|
||||
unsigned int openglVersion = NzOpenGL::GetVersion();
|
||||
unsigned int openglVersion = Nz::OpenGL::GetVersion();
|
||||
|
||||
// NzOpenGL nous donne accès à trois informations principales:
|
||||
// OpenGL nous donne accès à trois informations principales:
|
||||
// 1) La chaîne d'identification du driver ("Renderer name")
|
||||
// 2) La chaîne d'identification du concepteur ("Vendor name")
|
||||
// 3) La version d'OpenGL
|
||||
oss << "Identification: " << NzOpenGL::GetRendererName() << std::endl;
|
||||
oss << "Concepteur: " << NzOpenGL::GetVendorName() << std::endl;
|
||||
oss << "Identification: " << Nz::OpenGL::GetRendererName() << std::endl;
|
||||
oss << "Concepteur: " << Nz::OpenGL::GetVendorName() << std::endl;
|
||||
oss << "Version d'OpenGL: " << openglVersion/100 << '.' << openglVersion%100 << std::endl;
|
||||
oss << std::endl;
|
||||
|
||||
// Ainsi qu'un report des capacités de la carte graphique (avec le driver actuel)
|
||||
oss << "Rapport des capacites: " << std::endl; // Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça)
|
||||
printCap(oss, "-Calculs 64bits", NzOpenGL::IsSupported(nzOpenGLExtension_FP64));
|
||||
printCap(oss, "-Compression de textures (s3tc)", NzOpenGL::IsSupported(nzOpenGLExtension_TextureCompression_s3tc));
|
||||
printCap(oss, "-Filtrage anisotrope", NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter));
|
||||
printCap(oss, "-Framebuffer Object", NzOpenGL::IsSupported(nzOpenGLExtension_FrameBufferObject));
|
||||
printCap(oss, "-Mode debug", NzOpenGL::IsSupported(nzOpenGLExtension_DebugOutput));
|
||||
printCap(oss, "-Pixelbuffer Object", NzOpenGL::IsSupported(nzOpenGLExtension_PixelBufferObject));
|
||||
printCap(oss, "-Samplers Object", NzOpenGL::IsSupported(nzOpenGLExtension_SamplerObjects));
|
||||
printCap(oss, "-Separate shader objects", NzOpenGL::IsSupported(nzOpenGLExtension_SeparateShaderObjects));
|
||||
printCap(oss, "-Texture array", NzOpenGL::IsSupported(nzOpenGLExtension_TextureArray));
|
||||
printCap(oss, "-Texture storage", NzOpenGL::IsSupported(nzOpenGLExtension_TextureStorage));
|
||||
printCap(oss, "-Vertex array objects", NzOpenGL::IsSupported(nzOpenGLExtension_VertexArrayObjects));
|
||||
printCap(oss, "-Calculs 64bits", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_FP64));
|
||||
printCap(oss, "-Compression de textures (s3tc)", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_TextureCompression_s3tc));
|
||||
printCap(oss, "-Filtrage anisotrope", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_AnisotropicFilter));
|
||||
printCap(oss, "-Mode debug", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_DebugOutput));
|
||||
printCap(oss, "-Separate shader objects", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_SeparateShaderObjects));
|
||||
printCap(oss, "-Texture storage", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_TextureStorage));
|
||||
}
|
||||
else
|
||||
oss << "Impossible de retrouver les informations de la carte graphique" << std::endl;
|
||||
|
|
@ -99,14 +94,14 @@ int main()
|
|||
|
||||
std::cout << oss.str() << std::endl;
|
||||
|
||||
NzFile reportFile("RapportHardwareInfo.txt");
|
||||
if (reportFile.Open(nzOpenMode_Text | nzOpenMode_Truncate | nzOpenMode_WriteOnly))
|
||||
Nz::File reportFile("RapportNz::HardwareInfo.txt");
|
||||
if (reportFile.Open(Nz::OpenMode_Text | Nz::OpenMode_Truncate | Nz::OpenMode_WriteOnly))
|
||||
{
|
||||
reportFile.Write(oss.str()); // Conversion implicite en NzString
|
||||
reportFile.Write(oss.str()); // Conversion implicite en Nz::String
|
||||
reportFile.Close();
|
||||
|
||||
char accentAigu = static_cast<char>(130); // C'est crade, mais ça marche chez 95% des Windowsiens
|
||||
std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
|
||||
std::cout << "Un fichier (RapportNz::HardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << "Impossible de sauvegarder le rapport" << std::endl;
|
||||
|
|
@ -116,7 +111,7 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void printCap(std::ostream& o, const NzString& cap, bool b)
|
||||
void printCap(std::ostream& o, const Nz::String& cap, bool b)
|
||||
{
|
||||
if (b)
|
||||
o << cap << ": Oui" << std::endl;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
int main()
|
||||
{
|
||||
// Pour charger des ressources, il est impératif d'initialiser le module utilitaire
|
||||
NzInitializer<NzUtility> utility;
|
||||
Nz::Initializer<Nz::Utility> utility;
|
||||
if (!utility)
|
||||
{
|
||||
// Ça n'a pas fonctionné, le pourquoi se trouve dans le fichier NazaraLog.log
|
||||
|
|
@ -22,7 +22,7 @@ int main()
|
|||
|
||||
for (;;)
|
||||
{
|
||||
NzDirectory resourceDirectory("resources/");
|
||||
Nz::Directory resourceDirectory("resources/");
|
||||
if (!resourceDirectory.Open())
|
||||
{
|
||||
std::cerr << "Failed to open resource directory" << std::endl;
|
||||
|
|
@ -30,12 +30,12 @@ int main()
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::vector<NzString> models;
|
||||
std::vector<Nz::String> models;
|
||||
while (resourceDirectory.NextResult())
|
||||
{
|
||||
NzString path = resourceDirectory.GetResultName();
|
||||
NzString ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne
|
||||
if (NzMeshLoader::IsExtensionSupported(ext)) // L'extension est-elle supportée par le MeshLoader ?
|
||||
Nz::String path = resourceDirectory.GetResultName();
|
||||
Nz::String ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne
|
||||
if (Nz::MeshLoader::IsExtensionSupported(ext)) // L'extension est-elle supportée par le MeshLoader ?
|
||||
models.push_back(path);
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ int main()
|
|||
if (iChoice == 0)
|
||||
break;
|
||||
|
||||
NzMesh mesh;
|
||||
Nz::Mesh mesh;
|
||||
if (!mesh.LoadFromFile("resources/" + models[iChoice-1]))
|
||||
{
|
||||
std::cout << "Failed to load mesh" << std::endl;
|
||||
|
|
@ -77,11 +77,11 @@ int main()
|
|||
|
||||
switch (mesh.GetAnimationType())
|
||||
{
|
||||
case nzAnimationType_Skeletal:
|
||||
case Nz::AnimationType_Skeletal:
|
||||
std::cout << "This is a skeletal-animated mesh" << std::endl;
|
||||
break;
|
||||
|
||||
case nzAnimationType_Static:
|
||||
case Nz::AnimationType_Static:
|
||||
std::cout << "This is a static mesh" << std::endl;
|
||||
break;
|
||||
|
||||
|
|
@ -92,9 +92,9 @@ int main()
|
|||
|
||||
if (mesh.IsAnimable())
|
||||
{
|
||||
if (mesh.GetAnimationType() == nzAnimationType_Skeletal)
|
||||
if (mesh.GetAnimationType() == Nz::AnimationType_Skeletal)
|
||||
{
|
||||
const NzSkeleton* skeleton = mesh.GetSkeleton();
|
||||
const Nz::Skeleton* skeleton = mesh.GetSkeleton();
|
||||
unsigned int jointCount = skeleton->GetJointCount();
|
||||
std::cout << "It has a skeleton made of " << skeleton->GetJointCount() << " joint(s)." << std::endl;
|
||||
std::cout << "Print joints ? (Y/N) ";
|
||||
|
|
@ -107,10 +107,10 @@ int main()
|
|||
{
|
||||
for (unsigned int i = 0; i < jointCount; ++i)
|
||||
{
|
||||
const NzJoint* joint = skeleton->GetJoint(i);
|
||||
const Nz::Joint* joint = skeleton->GetJoint(i);
|
||||
std::cout << "\t" << (i+1) << ": " << joint->GetName();
|
||||
|
||||
const NzJoint* parent = static_cast<const NzJoint*>(joint->GetParent());
|
||||
const Nz::Joint* parent = static_cast<const Nz::Joint*>(joint->GetParent());
|
||||
if (parent)
|
||||
std::cout << " (Parent: " << parent->GetName() << ')';
|
||||
|
||||
|
|
@ -119,10 +119,10 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
NzString animationPath = mesh.GetAnimation();
|
||||
Nz::String animationPath = mesh.GetAnimation();
|
||||
if (!animationPath.IsEmpty())
|
||||
{
|
||||
NzAnimation animation;
|
||||
Nz::Animation animation;
|
||||
if (animation.LoadFromFile(animationPath))
|
||||
{
|
||||
unsigned int sequenceCount = animation.GetSequenceCount();
|
||||
|
|
@ -137,7 +137,7 @@ int main()
|
|||
{
|
||||
for (unsigned int i = 0; i < sequenceCount; ++i)
|
||||
{
|
||||
const NzSequence* sequence = animation.GetSequence(i);
|
||||
const Nz::Sequence* sequence = animation.GetSequence(i);
|
||||
std::cout << "\t" << (i+1) << ": " << sequence->name << std::endl;
|
||||
std::cout << "\t\tStart frame: " << sequence->firstFrame << std::endl;
|
||||
std::cout << "\t\tFrame count: " << sequence->frameCount << std::endl;
|
||||
|
|
@ -153,7 +153,7 @@ int main()
|
|||
std::cout << "It's animable but has no animation information" << std::endl;
|
||||
}
|
||||
|
||||
NzBoxf cube = mesh.GetAABB();
|
||||
Nz::Boxf cube = mesh.GetAABB();
|
||||
std::cout << "Mesh is " << cube.width << " units wide, " << cube.height << " units height and " << cube.depth << " units depth" << std::endl;
|
||||
|
||||
unsigned int materialCount = mesh.GetMaterialCount();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
template<typename T> void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount);
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T> void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount);
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/Algorithm.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Audio/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T>
|
||||
void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
|
||||
{
|
||||
///DOC: Le buffer d'entrée peut être le même que le buffer de sortie
|
||||
// Pour éviter l'overflow, on utilise comme accumulateur un type assez grand, (u)int 64 bits pour les entiers, double pour les flottants
|
||||
typedef typename std::conditional<std::is_unsigned<T>::value, nzUInt64, nzInt64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_unsigned<T>::value, UInt64, Int64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
|
||||
for (unsigned int i = 0; i < frameCount; ++i)
|
||||
|
|
@ -19,7 +21,8 @@ void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int fr
|
|||
for (unsigned int j = 0; j < channelCount; ++j)
|
||||
acc += input[i*channelCount + j];
|
||||
|
||||
output[i] = static_cast<T>(acc/channelCount);
|
||||
output[i] = static_cast<T>(acc / channelCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,34 +14,36 @@
|
|||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzAudio
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_AUDIO_API Audio
|
||||
{
|
||||
public:
|
||||
NzAudio() = delete;
|
||||
~NzAudio() = delete;
|
||||
Audio() = delete;
|
||||
~Audio() = delete;
|
||||
|
||||
static nzAudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
static AudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
static float GetDopplerFactor();
|
||||
static float GetGlobalVolume();
|
||||
static NzVector3f GetListenerDirection();
|
||||
static NzVector3f GetListenerPosition();
|
||||
static NzQuaternionf GetListenerRotation();
|
||||
static NzVector3f GetListenerVelocity();
|
||||
static Vector3f GetListenerDirection();
|
||||
static Vector3f GetListenerPosition();
|
||||
static Quaternionf GetListenerRotation();
|
||||
static Vector3f GetListenerVelocity();
|
||||
static float GetSpeedOfSound();
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsFormatSupported(nzAudioFormat format);
|
||||
static bool IsFormatSupported(AudioFormat format);
|
||||
static bool IsInitialized();
|
||||
|
||||
static void SetDopplerFactor(float dopplerFactor);
|
||||
static void SetGlobalVolume(float volume);
|
||||
static void SetListenerDirection(const NzVector3f& direction);
|
||||
static void SetListenerDirection(const Vector3f& direction);
|
||||
static void SetListenerDirection(float dirX, float dirY, float dirZ);
|
||||
static void SetListenerPosition(const NzVector3f& position);
|
||||
static void SetListenerPosition(const Vector3f& position);
|
||||
static void SetListenerPosition(float x, float y, float z);
|
||||
static void SetListenerRotation(const NzQuaternionf& rotation);
|
||||
static void SetListenerVelocity(const NzVector3f& velocity);
|
||||
static void SetListenerRotation(const Quaternionf& rotation);
|
||||
static void SetListenerVelocity(const Vector3f& velocity);
|
||||
static void SetListenerVelocity(float velX, float velY, float velZ);
|
||||
static void SetSpeedOfSound(float speed);
|
||||
|
||||
|
|
@ -49,6 +51,7 @@ class NAZARA_AUDIO_API NzAudio
|
|||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_AUDIO_HPP
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_AUDIO_MANAGE_MEMORY
|
||||
#undef NAZARA_AUDIO_MANAGE_MEMORY
|
||||
#define NAZARA_AUDIO_MANAGE_MEMORY 1
|
||||
#define NAZARA_AUDIO_MANAGE_MEMORY 0
|
||||
#endif
|
||||
|
||||
NazaraCheckTypeAndVal(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, integral, >, 0, " shall be a strictly positive integer");
|
||||
|
|
|
|||
|
|
@ -4,29 +4,32 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ENUMS_HPP
|
||||
#define NAZARA_ENUMS_HPP
|
||||
#ifndef NAZARA_ENUMS_AUDIO_HPP
|
||||
#define NAZARA_ENUMS_AUDIO_HPP
|
||||
|
||||
enum nzAudioFormat
|
||||
namespace Nz
|
||||
{
|
||||
nzAudioFormat_Unknown = -1,
|
||||
enum AudioFormat
|
||||
{
|
||||
AudioFormat_Unknown = -1,
|
||||
|
||||
// La valeur entière est le nombre de canaux possédés par ce format
|
||||
nzAudioFormat_Mono = 1,
|
||||
nzAudioFormat_Stereo = 2,
|
||||
nzAudioFormat_Quad = 4,
|
||||
nzAudioFormat_5_1 = 6,
|
||||
nzAudioFormat_6_1 = 7,
|
||||
nzAudioFormat_7_1 = 8,
|
||||
AudioFormat_Mono = 1,
|
||||
AudioFormat_Stereo = 2,
|
||||
AudioFormat_Quad = 4,
|
||||
AudioFormat_5_1 = 6,
|
||||
AudioFormat_6_1 = 7,
|
||||
AudioFormat_7_1 = 8,
|
||||
|
||||
nzAudioFormat_Max = nzAudioFormat_7_1
|
||||
};
|
||||
AudioFormat_Max = AudioFormat_7_1
|
||||
};
|
||||
|
||||
enum nzSoundStatus
|
||||
{
|
||||
nzSoundStatus_Playing,
|
||||
nzSoundStatus_Paused,
|
||||
nzSoundStatus_Stopped
|
||||
};
|
||||
enum SoundStatus
|
||||
{
|
||||
SoundStatus_Playing,
|
||||
SoundStatus_Paused,
|
||||
SoundStatus_Stopped
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_HPP
|
||||
#endif // NAZARA_ENUMS_AUDIO_HPP
|
||||
|
|
|
|||
|
|
@ -13,60 +13,68 @@
|
|||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
|
||||
struct NzMusicParams
|
||||
namespace Nz
|
||||
{
|
||||
struct MusicParams
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
};
|
||||
|
||||
class NzMusic;
|
||||
class NzSoundStream;
|
||||
class Music;
|
||||
class SoundStream;
|
||||
|
||||
using NzMusicLoader = NzResourceLoader<NzMusic, NzMusicParams>;
|
||||
using MusicLoader = ResourceLoader<Music, MusicParams>;
|
||||
|
||||
struct NzMusicImpl;
|
||||
struct MusicImpl;
|
||||
|
||||
class NAZARA_AUDIO_API NzMusic : public NzResource, public NzSoundEmitter, NzNonCopyable
|
||||
{
|
||||
friend NzMusicLoader;
|
||||
class NAZARA_AUDIO_API Music : public Resource, public SoundEmitter
|
||||
{
|
||||
friend MusicLoader;
|
||||
|
||||
public:
|
||||
NzMusic() = default;
|
||||
~NzMusic();
|
||||
Music() = default;
|
||||
Music(const Music&) = delete;
|
||||
Music(Music&&) = delete; ///TODO
|
||||
~Music();
|
||||
|
||||
bool Create(NzSoundStream* soundStream);
|
||||
bool Create(SoundStream* soundStream);
|
||||
void Destroy();
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
|
||||
nzUInt32 GetDuration() const;
|
||||
nzAudioFormat GetFormat() const;
|
||||
nzUInt32 GetPlayingOffset() const;
|
||||
unsigned int GetSampleCount() const;
|
||||
unsigned int GetSampleRate() const;
|
||||
nzSoundStatus GetStatus() const;
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
UInt32 GetPlayingOffset() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
SoundStatus GetStatus() const;
|
||||
|
||||
bool IsLooping() const;
|
||||
|
||||
bool OpenFromFile(const NzString& filePath, const NzMusicParams& params = NzMusicParams());
|
||||
bool OpenFromMemory(const void* data, std::size_t size, const NzMusicParams& params = NzMusicParams());
|
||||
bool OpenFromStream(NzInputStream& stream, const NzMusicParams& params = NzMusicParams());
|
||||
bool OpenFromFile(const String& filePath, const MusicParams& params = MusicParams());
|
||||
bool OpenFromMemory(const void* data, std::size_t size, const MusicParams& params = MusicParams());
|
||||
bool OpenFromStream(Stream& stream, const MusicParams& params = MusicParams());
|
||||
|
||||
void Pause();
|
||||
void Play();
|
||||
|
||||
void SetPlayingOffset(nzUInt32 offset);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop();
|
||||
|
||||
Music& operator=(const Music&) = delete;
|
||||
Music& operator=(Music&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
NzMusicImpl* m_impl = nullptr;
|
||||
MusicImpl* m_impl = nullptr;
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
|
||||
static NzMusicLoader::LoaderList s_loaders;
|
||||
};
|
||||
static MusicLoader::LoaderList s_loaders;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MUSIC_HPP
|
||||
|
|
|
|||
|
|
@ -20,168 +20,171 @@
|
|||
// Étant donné que les headers OpenAL ne nous permettent pas de n'avoir que les signatures sans les pointeurs de fonctions
|
||||
// Et que je ne souhaite pas les modifier, je suis contraint de les placer dans un espace de nom différent pour ensuite
|
||||
// remettre dans l'espace global les choses intéressantes (les typedef notamment)
|
||||
namespace NzOpenALDetail
|
||||
namespace OpenALDetail
|
||||
{
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
}
|
||||
|
||||
// Si quelqu'un a une meilleure idée ...
|
||||
using NzOpenALDetail::ALboolean;
|
||||
using NzOpenALDetail::ALbyte;
|
||||
using NzOpenALDetail::ALchar;
|
||||
using NzOpenALDetail::ALdouble;
|
||||
using NzOpenALDetail::ALenum;
|
||||
using NzOpenALDetail::ALfloat;
|
||||
using NzOpenALDetail::ALint;
|
||||
using NzOpenALDetail::ALshort;
|
||||
using NzOpenALDetail::ALsizei;
|
||||
using NzOpenALDetail::ALubyte;
|
||||
using NzOpenALDetail::ALuint;
|
||||
using NzOpenALDetail::ALushort;
|
||||
using NzOpenALDetail::ALvoid;
|
||||
using OpenALDetail::ALboolean;
|
||||
using OpenALDetail::ALbyte;
|
||||
using OpenALDetail::ALchar;
|
||||
using OpenALDetail::ALdouble;
|
||||
using OpenALDetail::ALenum;
|
||||
using OpenALDetail::ALfloat;
|
||||
using OpenALDetail::ALint;
|
||||
using OpenALDetail::ALshort;
|
||||
using OpenALDetail::ALsizei;
|
||||
using OpenALDetail::ALubyte;
|
||||
using OpenALDetail::ALuint;
|
||||
using OpenALDetail::ALushort;
|
||||
using OpenALDetail::ALvoid;
|
||||
|
||||
using NzOpenALDetail::ALCboolean;
|
||||
using NzOpenALDetail::ALCbyte;
|
||||
using NzOpenALDetail::ALCchar;
|
||||
using NzOpenALDetail::ALCcontext;
|
||||
using NzOpenALDetail::ALCdevice;
|
||||
using NzOpenALDetail::ALCdouble;
|
||||
using NzOpenALDetail::ALCenum;
|
||||
using NzOpenALDetail::ALCfloat;
|
||||
using NzOpenALDetail::ALCint;
|
||||
using NzOpenALDetail::ALCshort;
|
||||
using NzOpenALDetail::ALCsizei;
|
||||
using NzOpenALDetail::ALCubyte;
|
||||
using NzOpenALDetail::ALCuint;
|
||||
using NzOpenALDetail::ALCushort;
|
||||
using NzOpenALDetail::ALCvoid;
|
||||
using OpenALDetail::ALCboolean;
|
||||
using OpenALDetail::ALCbyte;
|
||||
using OpenALDetail::ALCchar;
|
||||
using OpenALDetail::ALCcontext;
|
||||
using OpenALDetail::ALCdevice;
|
||||
using OpenALDetail::ALCdouble;
|
||||
using OpenALDetail::ALCenum;
|
||||
using OpenALDetail::ALCfloat;
|
||||
using OpenALDetail::ALCint;
|
||||
using OpenALDetail::ALCshort;
|
||||
using OpenALDetail::ALCsizei;
|
||||
using OpenALDetail::ALCubyte;
|
||||
using OpenALDetail::ALCuint;
|
||||
using OpenALDetail::ALCushort;
|
||||
using OpenALDetail::ALCvoid;
|
||||
|
||||
using NzOpenALFunc = void (*)();
|
||||
|
||||
class NAZARA_AUDIO_API NzOpenAL
|
||||
namespace Nz
|
||||
{
|
||||
using OpenALFunc = void(*)();
|
||||
|
||||
class NAZARA_AUDIO_API OpenAL
|
||||
{
|
||||
public:
|
||||
static NzOpenALFunc GetEntry(const NzString& entryPoint);
|
||||
static NzString GetRendererName();
|
||||
static NzString GetVendorName();
|
||||
static OpenALFunc GetEntry(const String& entryPoint);
|
||||
static String GetRendererName();
|
||||
static String GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
|
||||
static bool Initialize(bool openDevice = true);
|
||||
|
||||
static bool IsInitialized();
|
||||
|
||||
static unsigned int QueryInputDevices(std::vector<NzString>& devices);
|
||||
static unsigned int QueryOutputDevices(std::vector<NzString>& devices);
|
||||
static unsigned int QueryInputDevices(std::vector<String>& devices);
|
||||
static unsigned int QueryOutputDevices(std::vector<String>& devices);
|
||||
|
||||
static bool SetDevice(const NzString& deviceName);
|
||||
static bool SetDevice(const String& deviceName);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
static ALenum AudioFormat[nzAudioFormat_Max+1];
|
||||
static ALenum AudioFormat[AudioFormat_Max + 1];
|
||||
|
||||
private:
|
||||
static void CloseDevice();
|
||||
static bool OpenDevice();
|
||||
static NzOpenALFunc LoadEntry(const char* name, bool throwException = false);
|
||||
};
|
||||
static OpenALFunc LoadEntry(const char* name, bool throwException = false);
|
||||
};
|
||||
}
|
||||
|
||||
// al
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFER3F alBuffer3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFER3I alBuffer3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERDATA alBufferData;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERF alBufferf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERFV alBufferfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERI alBufferi;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALBUFFERIV alBufferiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDELETEBUFFERS alDeleteBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDELETESOURCES alDeleteSources;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDISABLE alDisable;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDISTANCEMODEL alDistanceModel;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDOPPLERFACTOR alDopplerFactor;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALDOPPLERVELOCITY alDopplerVelocity;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALENABLE alEnable;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGENBUFFERS alGenBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGENSOURCES alGenSources;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBOOLEAN alGetBoolean;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBOOLEANV alGetBooleanv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFER3F alGetBuffer3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFER3I alGetBuffer3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERF alGetBufferf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERFV alGetBufferfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERI alGetBufferi;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETBUFFERIV alGetBufferiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETDOUBLE alGetDouble;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETDOUBLEV alGetDoublev;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETENUMVALUE alGetEnumValue;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETERROR alGetError;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETFLOAT alGetFloat;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETFLOATV alGetFloatv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETINTEGER alGetInteger;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETINTEGERV alGetIntegerv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENER3F alGetListener3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENER3I alGetListener3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERF alGetListenerf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERFV alGetListenerfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERI alGetListeneri;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETLISTENERIV alGetListeneriv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETPROCADDRESS alGetProcAddress;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCE3F alGetSource3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCE3I alGetSource3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEF alGetSourcef;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEFV alGetSourcefv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEI alGetSourcei;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSOURCEIV alGetSourceiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALGETSTRING alGetString;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISBUFFER alIsBuffer;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISENABLED alIsEnabled;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISEXTENSIONPRESENT alIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALISSOURCE alIsSource;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENER3F alListener3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENER3I alListener3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERF alListenerf;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERFV alListenerfv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERI alListeneri;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALLISTENERIV alListeneriv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCE3F alSource3f;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCE3I alSource3i;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEF alSourcef;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEFV alSourcefv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEI alSourcei;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEIV alSourceiv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPAUSE alSourcePause;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPAUSEV alSourcePausev;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPLAY alSourcePlay;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEPLAYV alSourcePlayv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEREWIND alSourceRewind;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEREWINDV alSourceRewindv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCESTOP alSourceStop;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCESTOPV alSourceStopv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALSPEEDOFSOUND alSpeedOfSound;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFER3F alBuffer3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFER3I alBuffer3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERDATA alBufferData;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERF alBufferf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERFV alBufferfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERI alBufferi;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFERIV alBufferiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDELETEBUFFERS alDeleteBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDELETESOURCES alDeleteSources;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDISABLE alDisable;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDISTANCEMODEL alDistanceModel;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDOPPLERFACTOR alDopplerFactor;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALDOPPLERVELOCITY alDopplerVelocity;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALENABLE alEnable;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGENBUFFERS alGenBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGENSOURCES alGenSources;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBOOLEAN alGetBoolean;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBOOLEANV alGetBooleanv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFER3F alGetBuffer3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFER3I alGetBuffer3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERF alGetBufferf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERFV alGetBufferfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERI alGetBufferi;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETBUFFERIV alGetBufferiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETDOUBLE alGetDouble;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETDOUBLEV alGetDoublev;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETENUMVALUE alGetEnumValue;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETERROR alGetError;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETFLOAT alGetFloat;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETFLOATV alGetFloatv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETINTEGER alGetInteger;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETINTEGERV alGetIntegerv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENER3F alGetListener3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENER3I alGetListener3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERF alGetListenerf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERFV alGetListenerfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERI alGetListeneri;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETLISTENERIV alGetListeneriv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETPROCADDRESS alGetProcAddress;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCE3F alGetSource3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCE3I alGetSource3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEF alGetSourcef;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEFV alGetSourcefv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEI alGetSourcei;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSOURCEIV alGetSourceiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALGETSTRING alGetString;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISBUFFER alIsBuffer;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISENABLED alIsEnabled;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISEXTENSIONPRESENT alIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALISSOURCE alIsSource;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENER3F alListener3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENER3I alListener3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERF alListenerf;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERFV alListenerfv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERI alListeneri;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALLISTENERIV alListeneriv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCE3F alSource3f;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCE3I alSource3i;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEF alSourcef;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEFV alSourcefv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEI alSourcei;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEIV alSourceiv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPAUSE alSourcePause;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPAUSEV alSourcePausev;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPLAY alSourcePlay;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEPLAYV alSourcePlayv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEREWIND alSourceRewind;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEREWINDV alSourceRewindv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCESTOP alSourceStop;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCESTOPV alSourceStopv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALSPEEDOFSOUND alSpeedOfSound;
|
||||
|
||||
// alc
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURESAMPLES alcCaptureSamples;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURESTART alcCaptureStart;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCAPTURESTOP alcCaptureStop;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCLOSEDEVICE alcCloseDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCCREATECONTEXT alcCreateContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCDESTROYCONTEXT alcDestroyContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETCURRENTCONTEXT alcGetCurrentContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETENUMVALUE alcGetEnumValue;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETERROR alcGetError;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETINTEGERV alcGetIntegerv;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETPROCADDRESS alcGetProcAddress;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCGETSTRING alcGetString;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCOPENDEVICE alcOpenDevice;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCPROCESSCONTEXT alcProcessContext;
|
||||
NAZARA_AUDIO_API extern NzOpenALDetail::LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURESAMPLES alcCaptureSamples;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURESTART alcCaptureStart;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCAPTURESTOP alcCaptureStop;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCLOSEDEVICE alcCloseDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCCREATECONTEXT alcCreateContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCDESTROYCONTEXT alcDestroyContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETCURRENTCONTEXT alcGetCurrentContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETENUMVALUE alcGetEnumValue;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETERROR alcGetError;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETINTEGERV alcGetIntegerv;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETPROCADDRESS alcGetProcAddress;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCGETSTRING alcGetString;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCOPENDEVICE alcOpenDevice;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCPROCESSCONTEXT alcProcessContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
|
||||
#endif // NAZARA_AUDIO_OPENAL
|
||||
|
||||
|
|
|
|||
|
|
@ -12,39 +12,46 @@
|
|||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzSound : public NzSoundEmitter
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_AUDIO_API Sound : public SoundEmitter
|
||||
{
|
||||
public:
|
||||
NzSound() = default;
|
||||
NzSound(const NzSoundBuffer* soundBuffer);
|
||||
NzSound(const NzSound& sound);
|
||||
~NzSound();
|
||||
Sound() = default;
|
||||
Sound(const SoundBuffer* soundBuffer);
|
||||
Sound(const Sound& sound);
|
||||
Sound(Sound&&) = default;
|
||||
~Sound();
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
|
||||
const NzSoundBuffer* GetBuffer() const;
|
||||
nzUInt32 GetDuration() const;
|
||||
nzUInt32 GetPlayingOffset() const;
|
||||
nzSoundStatus GetStatus() const;
|
||||
const SoundBuffer* GetBuffer() const;
|
||||
UInt32 GetDuration() const;
|
||||
UInt32 GetPlayingOffset() const;
|
||||
SoundStatus GetStatus() const;
|
||||
|
||||
bool IsLooping() const;
|
||||
bool IsPlayable() const;
|
||||
bool IsPlaying() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
void Pause();
|
||||
void Play();
|
||||
|
||||
void SetBuffer(const NzSoundBuffer* buffer);
|
||||
void SetPlayingOffset(nzUInt32 offset);
|
||||
void SetBuffer(const SoundBuffer* buffer);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop();
|
||||
|
||||
Sound& operator=(const Sound&) = delete; ///TODO?
|
||||
Sound& operator=(Sound&&) = default;
|
||||
|
||||
private:
|
||||
NzSoundBufferConstRef m_buffer;
|
||||
};
|
||||
SoundBufferConstRef m_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SOUND_HPP
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
|
|
@ -19,59 +17,67 @@
|
|||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
struct NzSoundBufferParams
|
||||
namespace Nz
|
||||
{
|
||||
struct SoundBufferParams
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
};
|
||||
|
||||
class NzSound;
|
||||
class NzSoundBuffer;
|
||||
class Sound;
|
||||
class SoundBuffer;
|
||||
|
||||
using NzSoundBufferConstRef = NzObjectRef<const NzSoundBuffer>;
|
||||
using NzSoundBufferLibrary = NzObjectLibrary<NzSoundBuffer>;
|
||||
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferManager = NzResourceManager<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferRef = NzObjectRef<NzSoundBuffer>;
|
||||
using SoundBufferConstRef = ObjectRef<const SoundBuffer>;
|
||||
using SoundBufferLibrary = ObjectLibrary<SoundBuffer>;
|
||||
using SoundBufferLoader = ResourceLoader<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferManager = ResourceManager<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferRef = ObjectRef<SoundBuffer>;
|
||||
|
||||
struct NzSoundBufferImpl;
|
||||
struct SoundBufferImpl;
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundBuffer : public NzRefCounted, public NzResource, NzNonCopyable
|
||||
{
|
||||
friend NzSound;
|
||||
friend NzSoundBufferLibrary;
|
||||
friend NzSoundBufferLoader;
|
||||
friend NzSoundBufferManager;
|
||||
friend class NzAudio;
|
||||
class NAZARA_AUDIO_API SoundBuffer : public RefCounted, public Resource
|
||||
{
|
||||
friend Sound;
|
||||
friend SoundBufferLibrary;
|
||||
friend SoundBufferLoader;
|
||||
friend SoundBufferManager;
|
||||
friend class Audio;
|
||||
|
||||
public:
|
||||
NzSoundBuffer() = default;
|
||||
NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples);
|
||||
~NzSoundBuffer();
|
||||
SoundBuffer() = default;
|
||||
SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
SoundBuffer(const SoundBuffer&) = delete;
|
||||
SoundBuffer(SoundBuffer&&) = delete;
|
||||
~SoundBuffer();
|
||||
|
||||
bool Create(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples);
|
||||
bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
void Destroy();
|
||||
|
||||
nzUInt32 GetDuration() const;
|
||||
nzAudioFormat GetFormat() const;
|
||||
const nzInt16* GetSamples() const;
|
||||
unsigned int GetSampleCount() const;
|
||||
unsigned int GetSampleRate() const;
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
const Int16* GetSamples() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzSoundBufferParams& params = NzSoundBufferParams());
|
||||
bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
static bool IsFormatSupported(nzAudioFormat format);
|
||||
template<typename... Args> static NzSoundBufferRef New(Args&&... args);
|
||||
static bool IsFormatSupported(AudioFormat format);
|
||||
template<typename... Args> static SoundBufferRef New(Args&&... args);
|
||||
|
||||
SoundBuffer& operator=(const SoundBuffer&) = delete;
|
||||
SoundBuffer& operator=(SoundBuffer&&) = delete; ///TODO
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSoundBufferDestroy, const NzSoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const NzSoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferDestroy, const SoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const SoundBuffer* /*soundBuffer*/);
|
||||
|
||||
private:
|
||||
unsigned int GetOpenALBuffer() const;
|
||||
|
|
@ -79,13 +85,14 @@ class NAZARA_AUDIO_API NzSoundBuffer : public NzRefCounted, public NzResource, N
|
|||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
NzSoundBufferImpl* m_impl = nullptr;
|
||||
SoundBufferImpl* m_impl = nullptr;
|
||||
|
||||
static NzSoundBufferLibrary::LibraryMap s_library;
|
||||
static NzSoundBufferLoader::LoaderList s_loaders;
|
||||
static NzSoundBufferManager::ManagerMap s_managerMap;
|
||||
static NzSoundBufferManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
static SoundBufferLibrary::LibraryMap s_library;
|
||||
static SoundBufferLoader::LoaderList s_loaders;
|
||||
static SoundBufferManager::ManagerMap s_managerMap;
|
||||
static SoundBufferManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/SoundBuffer.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,16 @@
|
|||
#include <memory>
|
||||
#include <Nazara/Audio/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzSoundBufferRef NzSoundBuffer::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzSoundBuffer> object(new NzSoundBuffer(std::forward<Args>(args)...));
|
||||
template<typename... Args>
|
||||
SoundBufferRef SoundBuffer::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<SoundBuffer> object(new SoundBuffer(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -10,28 +10,28 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
///TODO: Faire hériter SoundEmitter de Node
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundEmitter
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_AUDIO_API SoundEmitter
|
||||
{
|
||||
public:
|
||||
virtual ~NzSoundEmitter();
|
||||
virtual ~SoundEmitter();
|
||||
|
||||
virtual void EnableLooping(bool loop) = 0;
|
||||
void EnableSpatialization(bool spatialization);
|
||||
|
||||
float GetAttenuation() const;
|
||||
virtual nzUInt32 GetDuration() const = 0;
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
float GetMinDistance() const;
|
||||
float GetPitch() const;
|
||||
virtual nzUInt32 GetPlayingOffset() const = 0;
|
||||
NzVector3f GetPosition() const;
|
||||
NzVector3f GetVelocity() const;
|
||||
virtual nzSoundStatus GetStatus() const = 0;
|
||||
virtual UInt32 GetPlayingOffset() const = 0;
|
||||
Vector3f GetPosition() const;
|
||||
Vector3f GetVelocity() const;
|
||||
virtual SoundStatus GetStatus() const = 0;
|
||||
float GetVolume() const;
|
||||
|
||||
virtual bool IsLooping() const = 0;
|
||||
|
|
@ -43,21 +43,25 @@ class NAZARA_AUDIO_API NzSoundEmitter
|
|||
void SetAttenuation(float attenuation);
|
||||
void SetMinDistance(float minDistance);
|
||||
void SetPitch(float pitch);
|
||||
void SetPosition(const NzVector3f& position);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetPosition(float x, float y, float z);
|
||||
void SetVelocity(const NzVector3f& velocity);
|
||||
void SetVelocity(const Vector3f& velocity);
|
||||
void SetVelocity(float velX, float velY, float velZ);
|
||||
void SetVolume(float volume);
|
||||
|
||||
virtual void Stop() = 0;
|
||||
|
||||
protected:
|
||||
NzSoundEmitter();
|
||||
NzSoundEmitter(const NzSoundEmitter& emitter);
|
||||
SoundEmitter& operator=(const SoundEmitter&) = delete; ///TODO
|
||||
SoundEmitter& operator=(SoundEmitter&&) = delete; ///TODO
|
||||
|
||||
nzSoundStatus GetInternalStatus() const;
|
||||
protected:
|
||||
SoundEmitter();
|
||||
SoundEmitter(const SoundEmitter& emitter);
|
||||
SoundEmitter(SoundEmitter&&) = delete; ///TODO
|
||||
|
||||
SoundStatus GetInternalStatus() const;
|
||||
|
||||
unsigned int m_source;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // NAZARA_SOUNDEMITTER_HPP
|
||||
|
|
|
|||
|
|
@ -11,19 +11,22 @@
|
|||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundStream
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_AUDIO_API SoundStream
|
||||
{
|
||||
public:
|
||||
NzSoundStream() = default;
|
||||
virtual ~NzSoundStream();
|
||||
SoundStream() = default;
|
||||
virtual ~SoundStream();
|
||||
|
||||
virtual nzUInt32 GetDuration() const = 0;
|
||||
virtual nzAudioFormat GetFormat() const = 0;
|
||||
virtual nzUInt64 GetSampleCount() const = 0;
|
||||
virtual nzUInt32 GetSampleRate() const = 0;
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
virtual AudioFormat GetFormat() const = 0;
|
||||
virtual UInt32 GetSampleCount() const = 0;
|
||||
virtual UInt32 GetSampleRate() const = 0;
|
||||
|
||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||
virtual void Seek(nzUInt32 offset) = 0;
|
||||
};
|
||||
virtual void Seek(UInt32 offset) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SOUNDSTREAM_HPP
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// This file was automatically generated on 24 Jun 2015 at 13:55:50
|
||||
// This file was automatically generated on 20 Nov 2015 at 14:22:32
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
|
@ -49,19 +49,14 @@
|
|||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/GuillotineBinPack.hpp>
|
||||
#include <Nazara/Core/HardwareInfo.hpp>
|
||||
#include <Nazara/Core/Hash.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/OffsetOf.hpp>
|
||||
|
|
@ -74,6 +69,8 @@
|
|||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Semaphore.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/Serializer.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
|
@ -82,6 +79,7 @@
|
|||
#include <Nazara/Core/TaskScheduler.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
#include <Nazara/Core/Unserializer.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_CORE_HPP
|
||||
|
|
|
|||
|
|
@ -8,19 +8,33 @@
|
|||
#define NAZARA_ABSTRACTHASH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <memory>
|
||||
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_CORE_API NzAbstractHash : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzAbstractHash() = default;
|
||||
virtual ~NzAbstractHash();
|
||||
class ByteArray;
|
||||
|
||||
virtual void Append(const nzUInt8* data, unsigned int len) = 0;
|
||||
class NAZARA_CORE_API AbstractHash
|
||||
{
|
||||
public:
|
||||
AbstractHash() = default;
|
||||
AbstractHash(const AbstractHash&) = delete;
|
||||
AbstractHash(AbstractHash&&) = default;
|
||||
virtual ~AbstractHash();
|
||||
|
||||
virtual void Append(const UInt8* data, std::size_t len) = 0;
|
||||
virtual void Begin() = 0;
|
||||
virtual NzHashDigest End() = 0;
|
||||
};
|
||||
virtual ByteArray End() = 0;
|
||||
|
||||
virtual std::size_t GetDigestLength() const = 0;
|
||||
virtual const char* GetHashName() const = 0;
|
||||
|
||||
AbstractHash& operator=(const AbstractHash&) = delete;
|
||||
AbstractHash& operator=(AbstractHash&&) = default;
|
||||
|
||||
static std::unique_ptr<AbstractHash> Get(HashType hash);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACTHASH_HPP
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
/*!
|
||||
* \class Nz::AbstractLogger
|
||||
* \brief Logger interface
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ABSTRACTLOGGER_HPP
|
||||
#define NAZARA_ABSTRACTLOGGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API AbstractLogger
|
||||
{
|
||||
public:
|
||||
AbstractLogger() = default;
|
||||
virtual ~AbstractLogger();
|
||||
|
||||
virtual void EnableStdReplication(bool enable) = 0;
|
||||
|
||||
virtual bool IsStdReplicationEnabled() = 0;
|
||||
|
||||
virtual void Write(const String& string) = 0;
|
||||
virtual void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACTLOGGER_HPP
|
||||
|
|
@ -8,15 +8,36 @@
|
|||
#define NAZARA_ALGORITHM_CORE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename F, typename Tuple> auto NzApply(F&& fn, Tuple&& t);
|
||||
template<typename O, typename F, typename Tuple> auto NzApply(O& object, F&& fn, Tuple&& t);
|
||||
template<typename T> void NzHashCombine(std::size_t& seed, const T& v);
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractHash;
|
||||
class ByteArray;
|
||||
|
||||
template<typename T>
|
||||
struct NzTypeTag {};
|
||||
template<typename F, typename Tuple> auto Apply(F&& fn, Tuple&& t);
|
||||
template<typename O, typename F, typename Tuple> auto Apply(O& object, F&& fn, Tuple&& t);
|
||||
template<typename T> ByteArray ComputeHash(HashType hash, const T& v);
|
||||
template<typename T> ByteArray ComputeHash(AbstractHash* hash, const T& v);
|
||||
template<typename T> void HashCombine(std::size_t& seed, const T& v);
|
||||
|
||||
template<typename T>
|
||||
struct TypeTag {};
|
||||
|
||||
inline bool Serialize(SerializationContext& context, bool value);
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Serialize(SerializationContext& context, T value);
|
||||
|
||||
inline bool Unserialize(UnserializationContext& context, bool* value);
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Unserialize(UnserializationContext& context, T* value);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Algorithm.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,51 +6,152 @@
|
|||
// Merci à Ryan "FullMetal Alchemist" Lahfa
|
||||
// Merci aussi à Freedom de siteduzero.com
|
||||
|
||||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
// http://www.cppsamples.com/common-tasks/apply-tuple-to-function.html
|
||||
template<typename F, typename Tuple, size_t... S>
|
||||
auto NzApplyImplFunc(F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
namespace Nz
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
// http://www.cppsamples.com/common-tasks/apply-tuple-to-function.html
|
||||
template<typename F, typename Tuple, size_t... S>
|
||||
auto ApplyImplFunc(F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
{
|
||||
return std::forward<F>(fn)(std::get<S>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F, typename Tuple>
|
||||
auto NzApply(F&& fn, Tuple&& t)
|
||||
{
|
||||
constexpr std::size_t tSize = std::tuple_size<typename std::remove_reference<Tuple>::type>::value;
|
||||
|
||||
return NzApplyImplFunc(std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
|
||||
template<typename O, typename F, typename Tuple, size_t... S>
|
||||
auto NzApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
{
|
||||
template<typename O, typename F, typename Tuple, size_t... S>
|
||||
auto ApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
{
|
||||
return (object .* std::forward<F>(fn))(std::get<S>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename O, typename F, typename Tuple>
|
||||
auto NzApply(O& object, F&& fn, Tuple&& t)
|
||||
{
|
||||
template<typename F, typename Tuple>
|
||||
auto Apply(F&& fn, Tuple&& t)
|
||||
{
|
||||
constexpr std::size_t tSize = std::tuple_size<typename std::remove_reference<Tuple>::type>::value;
|
||||
|
||||
return NzApplyImplMethod(object, std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
// Algorithme venant de CityHash par Google
|
||||
// http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
|
||||
template<typename T>
|
||||
void NzHashCombine(std::size_t& seed, const T& v)
|
||||
{
|
||||
const nzUInt64 kMul = 0x9ddfea08eb382d69ULL;
|
||||
return Detail::ApplyImplFunc(std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
|
||||
template<typename O, typename F, typename Tuple>
|
||||
auto Apply(O& object, F&& fn, Tuple&& t)
|
||||
{
|
||||
constexpr std::size_t tSize = std::tuple_size<typename std::remove_reference<Tuple>::type>::value;
|
||||
|
||||
return Detail::ApplyImplMethod(object, std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ByteArray ComputeHash(HashType hash, const T& v)
|
||||
{
|
||||
return ComputeHash(AbstractHash::Get(hash).get(), v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ByteArray ComputeHash(AbstractHash* hash, const T& v)
|
||||
{
|
||||
hash->Begin();
|
||||
|
||||
HashAppend(hash, v);
|
||||
|
||||
return hash->End();
|
||||
}
|
||||
|
||||
// Algorithme venant de CityHash par Google
|
||||
// http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
|
||||
template<typename T>
|
||||
void HashCombine(std::size_t& seed, const T& v)
|
||||
{
|
||||
const UInt64 kMul = 0x9ddfea08eb382d69ULL;
|
||||
|
||||
std::hash<T> hasher;
|
||||
nzUInt64 a = (hasher(v) ^ seed) * kMul;
|
||||
UInt64 a = (hasher(v) ^ seed) * kMul;
|
||||
a ^= (a >> 47);
|
||||
|
||||
nzUInt64 b = (seed ^ a) * kMul;
|
||||
UInt64 b = (seed ^ a) * kMul;
|
||||
b ^= (b >> 47);
|
||||
|
||||
seed = static_cast<std::size_t>(b * kMul);
|
||||
}
|
||||
|
||||
inline bool Serialize(SerializationContext& context, bool value)
|
||||
{
|
||||
if (context.currentBitPos == 8)
|
||||
{
|
||||
context.currentBitPos = 0;
|
||||
context.currentByte = 0;
|
||||
}
|
||||
|
||||
if (value)
|
||||
context.currentByte |= 1 << context.currentBitPos;
|
||||
|
||||
if (++context.currentBitPos >= 8)
|
||||
return Serialize<UInt8>(context, context.currentByte);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Serialize(SerializationContext& context, T value)
|
||||
{
|
||||
// Flush bits if a writing is in progress
|
||||
if (context.currentBitPos != 8)
|
||||
{
|
||||
context.currentBitPos = 8;
|
||||
|
||||
if (!Serialize<UInt8>(context, context.currentByte))
|
||||
NazaraWarning("Failed to flush bits");
|
||||
}
|
||||
|
||||
if (context.endianness != Endianness_Unknown && context.endianness != GetPlatformEndianness())
|
||||
SwapBytes(&value, sizeof(T));
|
||||
|
||||
return context.stream->Write(&value, sizeof(T)) == sizeof(T);
|
||||
}
|
||||
|
||||
inline bool Unserialize(UnserializationContext& context, bool* value)
|
||||
{
|
||||
NazaraAssert(value, "Invalid data pointer");
|
||||
|
||||
if (context.currentBitPos == 8)
|
||||
{
|
||||
if (!Unserialize(context, &context.currentByte))
|
||||
return false;
|
||||
|
||||
context.currentBitPos = 0;
|
||||
}
|
||||
|
||||
if (value)
|
||||
*value = (context.currentByte & (1 << context.currentBitPos)) != 0;
|
||||
|
||||
context.currentBitPos++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Unserialize(UnserializationContext& context, T* value)
|
||||
{
|
||||
NazaraAssert(value, "Invalid data pointer");
|
||||
|
||||
// Reset bit position
|
||||
context.currentBitPos = 8;
|
||||
|
||||
if (context.stream->Read(value, sizeof(T)) == sizeof(T))
|
||||
{
|
||||
if (context.endianness != Endianness_Unknown && context.endianness != GetPlatformEndianness())
|
||||
SwapBytes(value, sizeof(T));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -12,24 +12,26 @@
|
|||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
class NzAbstractHash;
|
||||
|
||||
template<typename Block = nzUInt32, class Allocator = std::allocator<Block>>
|
||||
class NzBitset
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractHash;
|
||||
|
||||
template<typename Block = UInt32, class Allocator = std::allocator<Block>>
|
||||
class Bitset
|
||||
{
|
||||
static_assert(std::is_integral<Block>::value && std::is_unsigned<Block>::value, "Block must be a unsigned integral type");
|
||||
|
||||
public:
|
||||
class Bit;
|
||||
|
||||
NzBitset();
|
||||
explicit NzBitset(unsigned int bitCount, bool val = false);
|
||||
explicit NzBitset(const char* bits);
|
||||
NzBitset(const char* bits, unsigned int bitCount);
|
||||
NzBitset(const NzBitset& bitset) = default;
|
||||
explicit NzBitset(const NzString& bits);
|
||||
NzBitset(NzBitset&& bitset) noexcept = default;
|
||||
~NzBitset() = default;
|
||||
Bitset();
|
||||
explicit Bitset(unsigned int bitCount, bool val = false);
|
||||
explicit Bitset(const char* bits);
|
||||
Bitset(const char* bits, unsigned int bitCount);
|
||||
Bitset(const Bitset& bitset) = default;
|
||||
explicit Bitset(const String& bits);
|
||||
Bitset(Bitset&& bitset) noexcept = default;
|
||||
~Bitset() = default;
|
||||
|
||||
void Clear();
|
||||
unsigned int Count() const;
|
||||
|
|
@ -43,12 +45,12 @@ class NzBitset
|
|||
unsigned int GetCapacity() const;
|
||||
unsigned int GetSize() const;
|
||||
|
||||
void PerformsAND(const NzBitset& a, const NzBitset& b);
|
||||
void PerformsNOT(const NzBitset& a);
|
||||
void PerformsOR(const NzBitset& a, const NzBitset& b);
|
||||
void PerformsXOR(const NzBitset& a, const NzBitset& b);
|
||||
void PerformsAND(const Bitset& a, const Bitset& b);
|
||||
void PerformsNOT(const Bitset& a);
|
||||
void PerformsOR(const Bitset& a, const Bitset& b);
|
||||
void PerformsXOR(const Bitset& a, const Bitset& b);
|
||||
|
||||
bool Intersects(const NzBitset& bitset) const;
|
||||
bool Intersects(const Bitset& bitset) const;
|
||||
|
||||
void Reserve(unsigned int bitCount);
|
||||
void Resize(unsigned int bitCount, bool defaultVal = false);
|
||||
|
|
@ -60,7 +62,7 @@ class NzBitset
|
|||
void Set(unsigned int bit, bool val = true);
|
||||
void SetBlock(unsigned int i, Block block);
|
||||
|
||||
void Swap(NzBitset& bitset);
|
||||
void Swap(Bitset& bitset);
|
||||
|
||||
bool Test(unsigned int bit) const;
|
||||
bool TestAll() const;
|
||||
|
|
@ -68,7 +70,7 @@ class NzBitset
|
|||
bool TestNone() const;
|
||||
|
||||
template<typename T> T To() const;
|
||||
NzString ToString() const;
|
||||
String ToString() const;
|
||||
|
||||
void UnboundedReset(unsigned int bit);
|
||||
void UnboundedSet(unsigned int bit, bool val = true);
|
||||
|
|
@ -77,15 +79,15 @@ class NzBitset
|
|||
Bit operator[](int index);
|
||||
bool operator[](int index) const;
|
||||
|
||||
NzBitset operator~() const;
|
||||
Bitset operator~() const;
|
||||
|
||||
NzBitset& operator=(const NzBitset& bitset) = default;
|
||||
NzBitset& operator=(const NzString& bits);
|
||||
NzBitset& operator=(NzBitset&& bitset) noexcept = default;
|
||||
Bitset& operator=(const Bitset& bitset) = default;
|
||||
Bitset& operator=(const String& bits);
|
||||
Bitset& operator=(Bitset&& bitset) noexcept = default;
|
||||
|
||||
NzBitset& operator&=(const NzBitset& bitset);
|
||||
NzBitset& operator|=(const NzBitset& bitset);
|
||||
NzBitset& operator^=(const NzBitset& bitset);
|
||||
Bitset& operator&=(const Bitset& bitset);
|
||||
Bitset& operator|=(const Bitset& bitset);
|
||||
Bitset& operator^=(const Bitset& bitset);
|
||||
|
||||
static Block fullBitMask;
|
||||
static unsigned int bitsPerBlock;
|
||||
|
|
@ -102,39 +104,12 @@ class NzBitset
|
|||
|
||||
std::vector<Block, Allocator> m_blocks;
|
||||
unsigned int m_bitCount;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator==(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator!=(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<=(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>=(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
NzBitset<Block, Allocator> operator&(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
NzBitset<Block, Allocator> operator|(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
NzBitset<Block, Allocator> operator^(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
class NzBitset<Block, Allocator>::Bit
|
||||
{
|
||||
friend NzBitset<Block, Allocator>;
|
||||
template<typename Block, class Allocator>
|
||||
class Bitset<Block, Allocator>::Bit
|
||||
{
|
||||
friend Bitset<Block, Allocator>;
|
||||
|
||||
public:
|
||||
Bit(const Bit& bit) = default;
|
||||
|
|
@ -165,12 +140,40 @@ class NzBitset<Block, Allocator>::Bit
|
|||
|
||||
Block& m_block;
|
||||
Block m_mask;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator==(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator!=(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<=(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>=(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
Bitset<Block, Allocator> operator&(const Bitset<Block, Allocator>& lhs, const Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
Bitset<Block, Allocator> operator|(const Bitset<Block, Allocator>& lhs, const Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
Bitset<Block, Allocator> operator^(const Bitset<Block, Allocator>& lhs, const Bitset<Block, Allocator>& rhs);
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename Block, class Allocator>
|
||||
void swap(NzBitset<Block, Allocator>& lhs, NzBitset<Block, Allocator>& rhs);
|
||||
void swap(Nz::Bitset<Block, Allocator>& lhs, Nz::Bitset<Block, Allocator>& rhs);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Bitset.inl>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -8,16 +8,16 @@
|
|||
#define NAZARA_BYTEARRAY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NzAbstractHash;
|
||||
|
||||
class NAZARA_CORE_API NzByteArray : public NzHashable
|
||||
namespace Nz
|
||||
{
|
||||
using Container = std::vector<nzUInt8>;
|
||||
class AbstractHash;
|
||||
|
||||
class NAZARA_CORE_API ByteArray
|
||||
{
|
||||
using Container = std::vector<UInt8>;
|
||||
|
||||
public:
|
||||
// types:
|
||||
|
|
@ -35,17 +35,17 @@ class NAZARA_CORE_API NzByteArray : public NzHashable
|
|||
using value_type = Container::value_type;
|
||||
|
||||
// construct/destroy:
|
||||
inline NzByteArray() = default;
|
||||
inline explicit NzByteArray(size_type n);
|
||||
inline NzByteArray(const void* buffer, size_type n);
|
||||
inline NzByteArray(size_type n, value_type value);
|
||||
template <class InputIterator> NzByteArray(InputIterator first, InputIterator last);
|
||||
NzByteArray(const NzByteArray& other) = default;
|
||||
NzByteArray(NzByteArray&& other) = default;
|
||||
~NzByteArray() = default;
|
||||
inline ByteArray() = default;
|
||||
inline explicit ByteArray(size_type n);
|
||||
inline ByteArray(const void* buffer, size_type n);
|
||||
inline ByteArray(size_type n, value_type value);
|
||||
template <class InputIterator> ByteArray(InputIterator first, InputIterator last);
|
||||
ByteArray(const ByteArray& other) = default;
|
||||
ByteArray(ByteArray&& other) = default;
|
||||
~ByteArray() = default;
|
||||
|
||||
inline iterator Append(const void* buffer, size_type size);
|
||||
inline iterator Append(const NzByteArray& other);
|
||||
inline iterator Append(const ByteArray& other);
|
||||
template <class InputIterator> void Assign(InputIterator first, InputIterator last);
|
||||
inline void Assign(size_type n, value_type value);
|
||||
|
||||
|
|
@ -66,10 +66,10 @@ class NAZARA_CORE_API NzByteArray : public NzHashable
|
|||
inline const_pointer GetConstBuffer() const;
|
||||
inline size_type GetMaxSize() const noexcept;
|
||||
inline size_type GetSize() const noexcept;
|
||||
inline NzByteArray GetSubArray(const_iterator startPos, const_iterator endPos) const;
|
||||
inline ByteArray GetSubArray(const_iterator startPos, const_iterator endPos) const;
|
||||
|
||||
inline iterator Insert(const_iterator pos, const void* buffer, size_type n);
|
||||
inline iterator Insert(const_iterator pos, const NzByteArray& other);
|
||||
inline iterator Insert(const_iterator pos, const ByteArray& other);
|
||||
inline iterator Insert(const_iterator pos, size_type n, value_type byte);
|
||||
template <class InputIterator> iterator Insert(const_iterator pos, InputIterator first, InputIterator last);
|
||||
inline bool IsEmpty() const noexcept;
|
||||
|
|
@ -77,7 +77,7 @@ class NAZARA_CORE_API NzByteArray : public NzHashable
|
|||
inline void PopBack();
|
||||
inline void PopFront();
|
||||
inline iterator Prepend(const void* buffer, size_type size);
|
||||
inline iterator Prepend(const NzByteArray& other);
|
||||
inline iterator Prepend(const ByteArray& other);
|
||||
inline void PushBack(value_type byte);
|
||||
inline void PushFront(value_type byte);
|
||||
|
||||
|
|
@ -86,9 +86,10 @@ class NAZARA_CORE_API NzByteArray : public NzHashable
|
|||
inline void Resize(size_type newSize, value_type byte);
|
||||
|
||||
inline void ShrinkToFit();
|
||||
inline void Swap(NzByteArray& other);
|
||||
inline void Swap(ByteArray& other);
|
||||
|
||||
inline NzString ToString() const;
|
||||
inline String ToHex() const;
|
||||
inline String ToString() const;
|
||||
|
||||
// STL interface
|
||||
inline iterator begin() noexcept;
|
||||
|
|
@ -107,31 +108,32 @@ class NAZARA_CORE_API NzByteArray : public NzHashable
|
|||
inline size_type size() const noexcept;
|
||||
|
||||
// Operators
|
||||
NAZARA_CORE_API friend std::ostream& operator<<(std::ostream& out, const Nz::ByteArray& byteArray);
|
||||
|
||||
inline reference operator[](size_type pos);
|
||||
inline const_reference operator[](size_type pos) const;
|
||||
inline NzByteArray& operator=(const NzByteArray& array) = default;
|
||||
inline NzByteArray& operator=(NzByteArray&& array) = default;
|
||||
inline NzByteArray operator+(const NzByteArray& array) const;
|
||||
inline NzByteArray& operator+=(const NzByteArray& array);
|
||||
inline ByteArray& operator=(const ByteArray& array) = default;
|
||||
inline ByteArray& operator=(ByteArray&& array) = default;
|
||||
inline ByteArray operator+(const ByteArray& array) const;
|
||||
inline ByteArray& operator+=(const ByteArray& array);
|
||||
|
||||
inline bool operator==(const NzByteArray& rhs) const;
|
||||
inline bool operator!=(const NzByteArray& rhs) const;
|
||||
inline bool operator<(const NzByteArray& rhs) const;
|
||||
inline bool operator<=(const NzByteArray& rhs) const;
|
||||
inline bool operator>(const NzByteArray& rhs) const;
|
||||
inline bool operator>=(const NzByteArray& rhs) const;
|
||||
inline bool operator==(const ByteArray& rhs) const;
|
||||
inline bool operator!=(const ByteArray& rhs) const;
|
||||
inline bool operator<(const ByteArray& rhs) const;
|
||||
inline bool operator<=(const ByteArray& rhs) const;
|
||||
inline bool operator>(const ByteArray& rhs) const;
|
||||
inline bool operator>=(const ByteArray& rhs) const;
|
||||
|
||||
private:
|
||||
bool FillHash(NzAbstractHash* hash) const;
|
||||
|
||||
Container m_array;
|
||||
};
|
||||
};
|
||||
|
||||
NAZARA_CORE_API std::ostream& operator<<(std::ostream& out, const NzByteArray& byteArray);
|
||||
inline bool HashAppend(AbstractHash* hash, const ByteArray& byteArray);
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
void swap(NzByteArray& lhs, NzByteArray& rhs);
|
||||
void swap(Nz::ByteArray& lhs, Nz::ByteArray& rhs);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/ByteArray.inl>
|
||||
|
|
|
|||
|
|
@ -2,327 +2,356 @@
|
|||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
inline NzByteArray::NzByteArray(size_type n) :
|
||||
m_array()
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline ByteArray::ByteArray(size_type n) :
|
||||
m_array()
|
||||
{
|
||||
m_array.reserve(n);
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::NzByteArray(const void* buffer, size_type n) :
|
||||
m_array(static_cast<const_pointer>(buffer), static_cast<const_pointer>(buffer) + n)
|
||||
{
|
||||
}
|
||||
inline ByteArray::ByteArray(const void* buffer, size_type n) :
|
||||
m_array(static_cast<const_pointer>(buffer), static_cast<const_pointer>(buffer) + n)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzByteArray::NzByteArray(size_type n, const value_type value) :
|
||||
m_array(n, value)
|
||||
{
|
||||
}
|
||||
inline ByteArray::ByteArray(size_type n, const value_type value) :
|
||||
m_array(n, value)
|
||||
{
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
NzByteArray::NzByteArray(InputIterator first, InputIterator last) :
|
||||
m_array(first, last)
|
||||
{
|
||||
}
|
||||
template <class InputIterator>
|
||||
ByteArray::ByteArray(InputIterator first, InputIterator last) :
|
||||
m_array(first, last)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Append(const void* buffer, size_type n)
|
||||
{
|
||||
inline ByteArray::iterator ByteArray::Append(const void* buffer, size_type n)
|
||||
{
|
||||
return Insert(end(), static_cast<const_pointer>(buffer), static_cast<const_pointer>(buffer) + n);
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Append(const NzByteArray& other)
|
||||
{
|
||||
inline ByteArray::iterator ByteArray::Append(const ByteArray& other)
|
||||
{
|
||||
return Insert(end(), other.begin(), other.end());
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzByteArray::Assign(size_type n, value_type value)
|
||||
{
|
||||
inline void ByteArray::Assign(size_type n, value_type value)
|
||||
{
|
||||
m_array.assign(n, value);
|
||||
}
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
void NzByteArray::Assign(InputIterator first, InputIterator last)
|
||||
{
|
||||
template <class InputIterator>
|
||||
void ByteArray::Assign(InputIterator first, InputIterator last)
|
||||
{
|
||||
m_array.assign(first, last);
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::reference NzByteArray::Back()
|
||||
{
|
||||
inline ByteArray::reference ByteArray::Back()
|
||||
{
|
||||
return m_array.back();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reference NzByteArray::Back() const
|
||||
{
|
||||
inline ByteArray::const_reference ByteArray::Back() const
|
||||
{
|
||||
return m_array.back();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Erase(const_iterator pos)
|
||||
{
|
||||
return m_array.erase(pos);
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return m_array.erase(first, last);
|
||||
}
|
||||
|
||||
inline NzByteArray::reference NzByteArray::Front()
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reference NzByteArray::Front() const
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
|
||||
inline NzByteArray::allocator_type NzByteArray::GetAllocator() const
|
||||
{
|
||||
return m_array.get_allocator();
|
||||
}
|
||||
|
||||
inline NzByteArray::pointer NzByteArray::GetBuffer()
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::GetCapacity() const noexcept
|
||||
{
|
||||
return m_array.capacity();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_pointer NzByteArray::GetConstBuffer() const
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::GetMaxSize() const noexcept
|
||||
{
|
||||
return m_array.max_size();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::GetSize() const noexcept
|
||||
{
|
||||
return m_array.size();
|
||||
}
|
||||
|
||||
inline NzByteArray NzByteArray::GetSubArray(const_iterator startPos, const_iterator endPos) const
|
||||
{
|
||||
return NzByteArray(startPos, endPos);
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Insert(const_iterator pos, const void* buffer, size_type n)
|
||||
{
|
||||
return m_array.insert(pos, static_cast<const_pointer>(buffer), static_cast<const_pointer>(buffer) + n);
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Insert(const_iterator pos, const NzByteArray& other)
|
||||
{
|
||||
return m_array.insert(pos, other.begin(), other.end());
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Insert(const_iterator pos, size_type n, value_type byte)
|
||||
{
|
||||
return m_array.insert(pos, n, byte);
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
NzByteArray::iterator NzByteArray::Insert(const_iterator pos, InputIterator first, InputIterator last)
|
||||
{
|
||||
return m_array.insert(pos, first, last);
|
||||
}
|
||||
|
||||
inline bool NzByteArray::IsEmpty() const noexcept
|
||||
{
|
||||
return m_array.empty();
|
||||
}
|
||||
|
||||
inline void NzByteArray::PopBack()
|
||||
{
|
||||
Erase(end() - 1);
|
||||
}
|
||||
|
||||
inline void NzByteArray::PopFront()
|
||||
{
|
||||
Erase(begin());
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Prepend(const void* buffer, size_type n)
|
||||
{
|
||||
return Insert(begin(), buffer, n);
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Prepend(const NzByteArray& other)
|
||||
{
|
||||
return Insert(begin(), other);
|
||||
}
|
||||
|
||||
inline void NzByteArray::PushBack(const value_type byte)
|
||||
{
|
||||
m_array.push_back(byte);
|
||||
}
|
||||
|
||||
inline void NzByteArray::PushFront(const value_type byte)
|
||||
{
|
||||
m_array.insert(begin(), 1, byte);
|
||||
}
|
||||
|
||||
inline void NzByteArray::Reserve(size_type bufferSize)
|
||||
{
|
||||
m_array.reserve(bufferSize);
|
||||
}
|
||||
|
||||
inline void NzByteArray::Resize(size_type newSize)
|
||||
{
|
||||
m_array.resize(newSize);
|
||||
}
|
||||
|
||||
inline void NzByteArray::Resize(size_type newSize, const value_type byte)
|
||||
{
|
||||
m_array.resize(newSize, byte);
|
||||
}
|
||||
|
||||
inline void NzByteArray::ShrinkToFit()
|
||||
{
|
||||
inline void ByteArray::Clear(bool keepBuffer)
|
||||
{
|
||||
m_array.clear();
|
||||
if (!keepBuffer)
|
||||
m_array.shrink_to_fit();
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzByteArray::Swap(NzByteArray& other)
|
||||
{
|
||||
m_array.swap(other.m_array);
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::Erase(const_iterator pos)
|
||||
{
|
||||
return m_array.erase(pos);
|
||||
}
|
||||
|
||||
inline NzString NzByteArray::ToString() const
|
||||
{
|
||||
return NzString(reinterpret_cast<const char*>(GetConstBuffer()), GetSize());
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::Erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return m_array.erase(first, last);
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::begin() noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
inline ByteArray::reference ByteArray::Front()
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::begin() const noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
inline ByteArray::const_reference ByteArray::Front() const
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::cbegin() const noexcept
|
||||
{
|
||||
return m_array.cbegin();
|
||||
}
|
||||
inline ByteArray::allocator_type ByteArray::GetAllocator() const
|
||||
{
|
||||
return m_array.get_allocator();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::cend() const noexcept
|
||||
{
|
||||
return m_array.cend();
|
||||
}
|
||||
inline ByteArray::pointer ByteArray::GetBuffer()
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reverse_iterator NzByteArray::crbegin() const noexcept
|
||||
{
|
||||
return m_array.crbegin();
|
||||
}
|
||||
inline ByteArray::size_type ByteArray::GetCapacity() const noexcept
|
||||
{
|
||||
return m_array.capacity();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reverse_iterator NzByteArray::crend() const noexcept
|
||||
{
|
||||
return m_array.crend();
|
||||
}
|
||||
inline ByteArray::const_pointer ByteArray::GetConstBuffer() const
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
|
||||
inline bool NzByteArray::empty() const noexcept
|
||||
{
|
||||
inline ByteArray::size_type ByteArray::GetMaxSize() const noexcept
|
||||
{
|
||||
return m_array.max_size();
|
||||
}
|
||||
|
||||
inline ByteArray::size_type ByteArray::GetSize() const noexcept
|
||||
{
|
||||
return m_array.size();
|
||||
}
|
||||
|
||||
inline ByteArray ByteArray::GetSubArray(const_iterator startPos, const_iterator endPos) const
|
||||
{
|
||||
return ByteArray(startPos, endPos);
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, const void* buffer, size_type n)
|
||||
{
|
||||
return m_array.insert(pos, static_cast<const_pointer>(buffer), static_cast<const_pointer>(buffer) + n);
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, const ByteArray& other)
|
||||
{
|
||||
return m_array.insert(pos, other.begin(), other.end());
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, size_type n, value_type byte)
|
||||
{
|
||||
return m_array.insert(pos, n, byte);
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
ByteArray::iterator ByteArray::Insert(const_iterator pos, InputIterator first, InputIterator last)
|
||||
{
|
||||
return m_array.insert(pos, first, last);
|
||||
}
|
||||
|
||||
inline bool ByteArray::IsEmpty() const noexcept
|
||||
{
|
||||
return m_array.empty();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::end() noexcept
|
||||
{
|
||||
inline void ByteArray::PopBack()
|
||||
{
|
||||
Erase(end() - 1);
|
||||
}
|
||||
|
||||
inline void ByteArray::PopFront()
|
||||
{
|
||||
Erase(begin());
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::Prepend(const void* buffer, size_type n)
|
||||
{
|
||||
return Insert(begin(), buffer, n);
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::Prepend(const ByteArray& other)
|
||||
{
|
||||
return Insert(begin(), other);
|
||||
}
|
||||
|
||||
inline void ByteArray::PushBack(const value_type byte)
|
||||
{
|
||||
m_array.push_back(byte);
|
||||
}
|
||||
|
||||
inline void ByteArray::PushFront(const value_type byte)
|
||||
{
|
||||
m_array.insert(begin(), 1, byte);
|
||||
}
|
||||
|
||||
inline void ByteArray::Reserve(size_type bufferSize)
|
||||
{
|
||||
m_array.reserve(bufferSize);
|
||||
}
|
||||
|
||||
inline void ByteArray::Resize(size_type newSize)
|
||||
{
|
||||
m_array.resize(newSize);
|
||||
}
|
||||
|
||||
inline void ByteArray::Resize(size_type newSize, const value_type byte)
|
||||
{
|
||||
m_array.resize(newSize, byte);
|
||||
}
|
||||
|
||||
inline void ByteArray::ShrinkToFit()
|
||||
{
|
||||
m_array.shrink_to_fit();
|
||||
}
|
||||
|
||||
inline void ByteArray::Swap(ByteArray& other)
|
||||
{
|
||||
m_array.swap(other.m_array);
|
||||
}
|
||||
|
||||
inline String ByteArray::ToHex() const
|
||||
{
|
||||
std::size_t length = m_array.size() * 2;
|
||||
|
||||
String hexOutput(length, '\0');
|
||||
for (std::size_t i = 0; i < m_array.size(); ++i)
|
||||
std::sprintf(&hexOutput[i * 2], "%02x", m_array[i]);
|
||||
|
||||
return hexOutput;
|
||||
}
|
||||
|
||||
inline String ByteArray::ToString() const
|
||||
{
|
||||
return String(reinterpret_cast<const char*>(GetConstBuffer()), GetSize());
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::begin() noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
|
||||
inline ByteArray::const_iterator ByteArray::begin() const noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
|
||||
inline ByteArray::const_iterator ByteArray::cbegin() const noexcept
|
||||
{
|
||||
return m_array.cbegin();
|
||||
}
|
||||
|
||||
inline ByteArray::const_iterator ByteArray::cend() const noexcept
|
||||
{
|
||||
return m_array.cend();
|
||||
}
|
||||
|
||||
inline ByteArray::const_reverse_iterator ByteArray::crbegin() const noexcept
|
||||
{
|
||||
return m_array.crbegin();
|
||||
}
|
||||
|
||||
inline ByteArray::const_reverse_iterator ByteArray::crend() const noexcept
|
||||
{
|
||||
return m_array.crend();
|
||||
}
|
||||
|
||||
inline bool ByteArray::empty() const noexcept
|
||||
{
|
||||
return m_array.empty();
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::end() noexcept
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::end() const noexcept
|
||||
{
|
||||
inline ByteArray::const_iterator ByteArray::end() const noexcept
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::reverse_iterator NzByteArray::rbegin() noexcept
|
||||
{
|
||||
inline ByteArray::reverse_iterator ByteArray::rbegin() noexcept
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reverse_iterator NzByteArray::rbegin() const noexcept
|
||||
{
|
||||
inline ByteArray::const_reverse_iterator ByteArray::rbegin() const noexcept
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::reverse_iterator NzByteArray::rend() noexcept
|
||||
{
|
||||
inline ByteArray::reverse_iterator ByteArray::rend() noexcept
|
||||
{
|
||||
return m_array.rend();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::size() const noexcept
|
||||
{
|
||||
inline ByteArray::size_type ByteArray::size() const noexcept
|
||||
{
|
||||
return GetSize();
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::reference NzByteArray::operator[](size_type pos)
|
||||
{
|
||||
inline ByteArray::reference ByteArray::operator[](size_type pos)
|
||||
{
|
||||
NazaraAssert(pos < GetSize(), "Index out of range");
|
||||
|
||||
return m_array[pos];
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reference NzByteArray::operator[](size_type pos) const
|
||||
{
|
||||
inline ByteArray::const_reference ByteArray::operator[](size_type pos) const
|
||||
{
|
||||
NazaraAssert(pos < GetSize(), "Index out of range");
|
||||
|
||||
return m_array[pos];
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray NzByteArray::operator+(const NzByteArray& other) const
|
||||
{
|
||||
NzByteArray tmp(*this);
|
||||
inline ByteArray ByteArray::operator+(const ByteArray& other) const
|
||||
{
|
||||
ByteArray tmp(*this);
|
||||
tmp += other;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
inline NzByteArray& NzByteArray::operator+=(const NzByteArray& other)
|
||||
{
|
||||
inline ByteArray& ByteArray::operator+=(const ByteArray& other)
|
||||
{
|
||||
Append(other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator==(const NzByteArray& rhs) const
|
||||
{
|
||||
inline bool ByteArray::operator==(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array == rhs.m_array;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator!=(const NzByteArray& rhs) const
|
||||
{
|
||||
inline bool ByteArray::operator!=(const ByteArray& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator<(const NzByteArray& rhs) const
|
||||
{
|
||||
inline bool ByteArray::operator<(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array < rhs.m_array;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator<=(const NzByteArray& rhs) const
|
||||
{
|
||||
inline bool ByteArray::operator<=(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array <= rhs.m_array;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator>(const NzByteArray& rhs) const
|
||||
{
|
||||
inline bool ByteArray::operator>(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array > rhs.m_array;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator>=(const NzByteArray& rhs) const
|
||||
{
|
||||
inline bool ByteArray::operator>=(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array >= rhs.m_array;
|
||||
}
|
||||
|
||||
inline bool HashAppend(AbstractHash* hash, const ByteArray& byteArray)
|
||||
{
|
||||
hash->Append(byteArray.GetConstBuffer(), byteArray.GetSize());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
inline void swap(NzByteArray& lhs, NzByteArray& rhs)
|
||||
inline void swap(Nz::ByteArray& lhs, Nz::ByteArray& rhs)
|
||||
{
|
||||
lhs.Swap(rhs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,23 +8,30 @@
|
|||
#define NAZARA_CALLONEXIT_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <functional>
|
||||
|
||||
class NzCallOnExit : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
class CallOnExit
|
||||
{
|
||||
using Func = std::function<void()>;
|
||||
|
||||
public:
|
||||
NzCallOnExit(Func func = nullptr);
|
||||
~NzCallOnExit();
|
||||
CallOnExit(Func func = nullptr);
|
||||
CallOnExit(const CallOnExit&) = delete;
|
||||
CallOnExit(CallOnExit&&) = delete;
|
||||
~CallOnExit();
|
||||
|
||||
void CallAndReset(Func func = nullptr);
|
||||
void Reset(Func func = nullptr);
|
||||
|
||||
CallOnExit& operator=(const CallOnExit&) = delete;
|
||||
CallOnExit& operator=(CallOnExit&&) = default;
|
||||
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/CallOnExit.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,28 +5,31 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline NzCallOnExit::NzCallOnExit(Func func) :
|
||||
m_func(func)
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
inline CallOnExit::CallOnExit(Func func) :
|
||||
m_func(func)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzCallOnExit::~NzCallOnExit()
|
||||
{
|
||||
inline CallOnExit::~CallOnExit()
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::CallAndReset(Func func)
|
||||
{
|
||||
inline void CallOnExit::CallAndReset(Func func)
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
|
||||
Reset(func);
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::Reset(Func func)
|
||||
{
|
||||
inline void CallOnExit::Reset(Func func)
|
||||
{
|
||||
m_func = func;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -15,15 +15,19 @@
|
|||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NAZARA_CORE_API NzClock
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API Clock
|
||||
{
|
||||
public:
|
||||
NzClock(nzUInt64 startingValue = 0, bool paused = false);
|
||||
NzClock(const NzClock& clock) = default;
|
||||
Clock(UInt64 startingValue = 0, bool paused = false);
|
||||
Clock(const Clock& clock) = default;
|
||||
Clock(Clock&& clock) = default;
|
||||
~Clock() = default;
|
||||
|
||||
float GetSeconds() const;
|
||||
nzUInt64 GetMicroseconds() const;
|
||||
nzUInt64 GetMilliseconds() const;
|
||||
UInt64 GetMicroseconds() const;
|
||||
UInt64 GetMilliseconds() const;
|
||||
|
||||
bool IsPaused() const;
|
||||
|
||||
|
|
@ -31,19 +35,21 @@ class NAZARA_CORE_API NzClock
|
|||
void Restart();
|
||||
void Unpause();
|
||||
|
||||
NzClock& operator=(const NzClock& clock) = default;
|
||||
Clock& operator=(const Clock& clock) = default;
|
||||
Clock& operator=(Clock&& clock) = default;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
nzUInt64 m_elapsedTime;
|
||||
nzUInt64 m_refTime;
|
||||
UInt64 m_elapsedTime;
|
||||
UInt64 m_refTime;
|
||||
bool m_paused;
|
||||
};
|
||||
};
|
||||
|
||||
typedef nzUInt64 (*NzClockFunction)();
|
||||
typedef UInt64 (*ClockFunction)();
|
||||
|
||||
extern NAZARA_CORE_API NzClockFunction NzGetMicroseconds;
|
||||
extern NAZARA_CORE_API NzClockFunction NzGetMilliseconds;
|
||||
extern NAZARA_CORE_API ClockFunction GetElapsedMicroseconds;
|
||||
extern NAZARA_CORE_API ClockFunction GetElapsedMilliseconds;
|
||||
}
|
||||
|
||||
#endif // NAZARA_CLOCK_HPP
|
||||
|
|
|
|||
|
|
@ -11,57 +11,60 @@
|
|||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
class NzColor
|
||||
namespace Nz
|
||||
{
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
inline NzColor();
|
||||
inline NzColor(nzUInt8 red, nzUInt8 green, nzUInt8 blue, nzUInt8 alpha = 255);
|
||||
inline explicit NzColor(nzUInt8 lightness);
|
||||
inline NzColor(nzUInt8 color[3], nzUInt8 alpha = 255);
|
||||
inline NzColor(const NzColor& color) = default;
|
||||
inline ~NzColor() = default;
|
||||
inline Color();
|
||||
inline Color(UInt8 red, UInt8 green, UInt8 blue, UInt8 alpha = 255);
|
||||
inline explicit Color(UInt8 lightness);
|
||||
inline Color(UInt8 color[3], UInt8 alpha = 255);
|
||||
inline Color(const Color& color) = default;
|
||||
inline ~Color() = default;
|
||||
|
||||
inline NzString ToString() const;
|
||||
inline String ToString() const;
|
||||
|
||||
inline NzColor operator+(const NzColor& angles) const;
|
||||
inline NzColor operator*(const NzColor& angles) const;
|
||||
inline Color operator+(const Color& angles) const;
|
||||
inline Color operator*(const Color& angles) const;
|
||||
|
||||
inline NzColor operator+=(const NzColor& angles);
|
||||
inline NzColor operator*=(const NzColor& angles);
|
||||
inline Color operator+=(const Color& angles);
|
||||
inline Color operator*=(const Color& angles);
|
||||
|
||||
inline bool operator==(const NzColor& angles) const;
|
||||
inline bool operator!=(const NzColor& angles) const;
|
||||
inline bool operator==(const Color& angles) const;
|
||||
inline bool operator!=(const Color& angles) const;
|
||||
|
||||
static inline NzColor FromCMY(float cyan, float magenta, float yellow);
|
||||
static inline NzColor FromCMYK(float cyan, float magenta, float yellow, float black);
|
||||
static inline NzColor FromHSL(nzUInt8 hue, nzUInt8 saturation, nzUInt8 lightness);
|
||||
static inline NzColor FromHSV(float hue, float saturation, float value);
|
||||
static inline NzColor FromXYZ(const NzVector3f& vec);
|
||||
static inline NzColor FromXYZ(float x, float y, float z);
|
||||
static inline void ToCMY(const NzColor& color, float* cyan, float* magenta, float* yellow);
|
||||
static inline void ToCMYK(const NzColor& color, float* cyan, float* magenta, float* yellow, float* black);
|
||||
static inline void ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturation, nzUInt8* lightness);
|
||||
static inline void ToHSV(const NzColor& color, float* hue, float* saturation, float* value);
|
||||
static inline void ToXYZ(const NzColor& color, NzVector3f* vec);
|
||||
static inline void ToXYZ(const NzColor& color, float* x, float* y, float* z);
|
||||
static inline Color FromCMY(float cyan, float magenta, float yellow);
|
||||
static inline Color FromCMYK(float cyan, float magenta, float yellow, float black);
|
||||
static inline Color FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness);
|
||||
static inline Color FromHSV(float hue, float saturation, float value);
|
||||
static inline Color FromXYZ(const Vector3f& vec);
|
||||
static inline Color FromXYZ(float x, float y, float z);
|
||||
static inline void ToCMY(const Color& color, float* cyan, float* magenta, float* yellow);
|
||||
static inline void ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black);
|
||||
static inline void ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness);
|
||||
static inline void ToHSV(const Color& color, float* hue, float* saturation, float* value);
|
||||
static inline void ToXYZ(const Color& color, Vector3f* vec);
|
||||
static inline void ToXYZ(const Color& color, float* x, float* y, float* z);
|
||||
|
||||
nzUInt8 r, g, b, a;
|
||||
UInt8 r, g, b, a;
|
||||
|
||||
static NAZARA_CORE_API const NzColor Black;
|
||||
static NAZARA_CORE_API const NzColor Blue;
|
||||
static NAZARA_CORE_API const NzColor Cyan;
|
||||
static NAZARA_CORE_API const NzColor Green;
|
||||
static NAZARA_CORE_API const NzColor Magenta;
|
||||
static NAZARA_CORE_API const NzColor Orange;
|
||||
static NAZARA_CORE_API const NzColor Red;
|
||||
static NAZARA_CORE_API const NzColor Yellow;
|
||||
static NAZARA_CORE_API const NzColor White;
|
||||
static NAZARA_CORE_API const Color Black;
|
||||
static NAZARA_CORE_API const Color Blue;
|
||||
static NAZARA_CORE_API const Color Cyan;
|
||||
static NAZARA_CORE_API const Color Green;
|
||||
static NAZARA_CORE_API const Color Magenta;
|
||||
static NAZARA_CORE_API const Color Orange;
|
||||
static NAZARA_CORE_API const Color Red;
|
||||
static NAZARA_CORE_API const Color Yellow;
|
||||
static NAZARA_CORE_API const Color White;
|
||||
|
||||
private:
|
||||
static float Hue2RGB(float v1, float v2, float vH);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const NzColor& color);
|
||||
std::ostream& operator<<(std::ostream& out, const Nz::Color& color);
|
||||
|
||||
#include <Nazara/Core/Color.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,37 +9,39 @@
|
|||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline NzColor::NzColor()
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
inline Color::Color()
|
||||
{
|
||||
}
|
||||
|
||||
inline NzColor::NzColor(nzUInt8 red, nzUInt8 green, nzUInt8 blue, nzUInt8 alpha) :
|
||||
r(red),
|
||||
g(green),
|
||||
b(blue),
|
||||
a(alpha)
|
||||
{
|
||||
}
|
||||
inline Color::Color(UInt8 red, UInt8 green, UInt8 blue, UInt8 alpha) :
|
||||
r(red),
|
||||
g(green),
|
||||
b(blue),
|
||||
a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzColor::NzColor(nzUInt8 lightness) :
|
||||
r(lightness),
|
||||
g(lightness),
|
||||
b(lightness),
|
||||
a(255)
|
||||
{
|
||||
}
|
||||
inline Color::Color(UInt8 lightness) :
|
||||
r(lightness),
|
||||
g(lightness),
|
||||
b(lightness),
|
||||
a(255)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzColor::NzColor(nzUInt8 vec[3], nzUInt8 alpha) :
|
||||
r(vec[0]),
|
||||
g(vec[1]),
|
||||
b(vec[2]),
|
||||
a(alpha)
|
||||
{
|
||||
}
|
||||
inline Color::Color(UInt8 vec[3], UInt8 alpha) :
|
||||
r(vec[0]),
|
||||
g(vec[1]),
|
||||
b(vec[2]),
|
||||
a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzString NzColor::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
inline String Color::ToString() const
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Color(" << static_cast<int>(r) << ", " << static_cast<int>(g) << ", " << static_cast<int>(b);
|
||||
|
||||
if (a != 255)
|
||||
|
|
@ -48,70 +50,72 @@ inline NzString NzColor::ToString() const
|
|||
ss << ')';
|
||||
|
||||
return ss;
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::operator+(const NzColor& color) const
|
||||
{
|
||||
NzColor c;
|
||||
c.r = std::min(static_cast<unsigned int>(r) + static_cast<unsigned int>(color.r), 255U);
|
||||
c.g = std::min(static_cast<unsigned int>(g) + static_cast<unsigned int>(color.g), 255U);
|
||||
c.b = std::min(static_cast<unsigned int>(b) + static_cast<unsigned int>(color.b), 255U);
|
||||
c.a = std::min(static_cast<unsigned int>(a) + static_cast<unsigned int>(color.a), 255U);
|
||||
inline Color Color::operator+(const Color& color) const
|
||||
{
|
||||
///TODO: Improve this shit
|
||||
Color c;
|
||||
c.r = static_cast<UInt8>(std::min(static_cast<unsigned int>(r) + static_cast<unsigned int>(color.r), 255U));
|
||||
c.g = static_cast<UInt8>(std::min(static_cast<unsigned int>(g) + static_cast<unsigned int>(color.g), 255U));
|
||||
c.b = static_cast<UInt8>(std::min(static_cast<unsigned int>(b) + static_cast<unsigned int>(color.b), 255U));
|
||||
c.a = static_cast<UInt8>(std::min(static_cast<unsigned int>(a) + static_cast<unsigned int>(color.a), 255U));
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::operator*(const NzColor& color) const
|
||||
{
|
||||
NzColor c;
|
||||
c.r = (static_cast<unsigned int>(r) * static_cast<unsigned int>(color.r)) / 255U;
|
||||
c.g = (static_cast<unsigned int>(g) * static_cast<unsigned int>(color.g)) / 255U;
|
||||
c.b = (static_cast<unsigned int>(b) * static_cast<unsigned int>(color.b)) / 255U;
|
||||
c.a = (static_cast<unsigned int>(a) * static_cast<unsigned int>(color.a)) / 255U;
|
||||
inline Color Color::operator*(const Color& color) const
|
||||
{
|
||||
///TODO: Improve this shit
|
||||
Color c;
|
||||
c.r = static_cast<UInt8>((static_cast<unsigned int>(r) * static_cast<unsigned int>(color.r)) / 255U);
|
||||
c.g = static_cast<UInt8>((static_cast<unsigned int>(g) * static_cast<unsigned int>(color.g)) / 255U);
|
||||
c.b = static_cast<UInt8>((static_cast<unsigned int>(b) * static_cast<unsigned int>(color.b)) / 255U);
|
||||
c.a = static_cast<UInt8>((static_cast<unsigned int>(a) * static_cast<unsigned int>(color.a)) / 255U);
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::operator+=(const NzColor& color)
|
||||
{
|
||||
inline Color Color::operator+=(const Color& color)
|
||||
{
|
||||
return operator=(operator+(color));
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::operator*=(const NzColor& color)
|
||||
{
|
||||
inline Color Color::operator*=(const Color& color)
|
||||
{
|
||||
return operator=(operator*(color));
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzColor::operator==(const NzColor& color) const
|
||||
{
|
||||
inline bool Color::operator==(const Color& color) const
|
||||
{
|
||||
return r == color.r && g == color.g && b == color.b && a == color.a;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool NzColor::operator!=(const NzColor& color) const
|
||||
{
|
||||
inline bool Color::operator!=(const Color& color) const
|
||||
{
|
||||
return !operator==(color);
|
||||
}
|
||||
}
|
||||
|
||||
// Algorithmes venant de http://www.easyrgb.com/index.php?X=MATH
|
||||
// Algorithmes venant de http://www.easyrgb.com/index.php?X=MATH
|
||||
|
||||
inline NzColor NzColor::FromCMY(float cyan, float magenta, float yellow)
|
||||
{
|
||||
return NzColor(static_cast<nzUInt8>((1.f-cyan)*255.f), static_cast<nzUInt8>((1.f-magenta)*255.f), static_cast<nzUInt8>((1.f-yellow)*255.f));
|
||||
}
|
||||
inline Color Color::FromCMY(float cyan, float magenta, float yellow)
|
||||
{
|
||||
return Color(static_cast<UInt8>((1.f-cyan)*255.f), static_cast<UInt8>((1.f-magenta)*255.f), static_cast<UInt8>((1.f-yellow)*255.f));
|
||||
}
|
||||
|
||||
inline NzColor NzColor::FromCMYK(float cyan, float magenta, float yellow, float black)
|
||||
{
|
||||
inline Color Color::FromCMYK(float cyan, float magenta, float yellow, float black)
|
||||
{
|
||||
return FromCMY(cyan * (1.f - black) + black,
|
||||
magenta * (1.f - black) + black,
|
||||
yellow * (1.f - black) + black);
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::FromHSL(nzUInt8 hue, nzUInt8 saturation, nzUInt8 lightness)
|
||||
{
|
||||
inline Color Color::FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness)
|
||||
{
|
||||
if (saturation == 0)
|
||||
{
|
||||
// RGB results from 0 to 255
|
||||
return NzColor(lightness * 255,
|
||||
return Color(lightness * 255,
|
||||
lightness * 255,
|
||||
lightness * 255);
|
||||
}
|
||||
|
|
@ -130,22 +134,22 @@ inline NzColor NzColor::FromHSL(nzUInt8 hue, nzUInt8 saturation, nzUInt8 lightne
|
|||
|
||||
float v1 = 2.f * l - v2;
|
||||
|
||||
return NzColor(static_cast<nzUInt8>(255.f * Hue2RGB(v1, v2, h + (1.f/3.f))),
|
||||
static_cast<nzUInt8>(255.f * Hue2RGB(v1, v2, h)),
|
||||
static_cast<nzUInt8>(255.f * Hue2RGB(v1, v2, h - (1.f/3.f))));
|
||||
return Color(static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h + (1.f/3.f))),
|
||||
static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h)),
|
||||
static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h - (1.f/3.f))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::FromHSV(float hue, float saturation, float value)
|
||||
{
|
||||
if (NzNumberEquals(saturation, 0.f))
|
||||
return NzColor(static_cast<nzUInt8>(value * 255.f));
|
||||
inline Color Color::FromHSV(float hue, float saturation, float value)
|
||||
{
|
||||
if (NumberEquals(saturation, 0.f))
|
||||
return Color(static_cast<UInt8>(value * 255.f));
|
||||
else
|
||||
{
|
||||
float h = hue/360.f * 6.f;
|
||||
float s = saturation/360.f;
|
||||
|
||||
if (NzNumberEquals(h, 6.f))
|
||||
if (NumberEquals(h, 6.f))
|
||||
h = 0; // hue must be < 1
|
||||
|
||||
int i = static_cast<unsigned int>(h);
|
||||
|
|
@ -194,16 +198,16 @@ inline NzColor NzColor::FromHSV(float hue, float saturation, float value)
|
|||
}
|
||||
|
||||
// RGB results from 0 to 255
|
||||
return NzColor(static_cast<nzUInt8>(r*255.f), static_cast<nzUInt8>(g*255.f), static_cast<nzUInt8>(b*255.f));
|
||||
return Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
|
||||
}
|
||||
}
|
||||
inline NzColor NzColor::FromXYZ(const NzVector3f& vec)
|
||||
{
|
||||
}
|
||||
inline Color Color::FromXYZ(const Vector3f& vec)
|
||||
{
|
||||
return FromXYZ(vec.x, vec.y, vec.z);
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::FromXYZ(float x, float y, float z)
|
||||
{
|
||||
inline Color Color::FromXYZ(float x, float y, float z)
|
||||
{
|
||||
x /= 100.f; // X from 0 to 95.047
|
||||
y /= 100.f; // Y from 0 to 100.000
|
||||
z /= 100.f; // Z from 0 to 108.883
|
||||
|
|
@ -227,24 +231,24 @@ inline NzColor NzColor::FromXYZ(float x, float y, float z)
|
|||
else
|
||||
b *= 12.92f;
|
||||
|
||||
return NzColor(static_cast<nzUInt8>(r * 255.f), static_cast<nzUInt8>(g * 255.f), static_cast<nzUInt8>(b * 255.f));
|
||||
}
|
||||
return Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
}
|
||||
|
||||
inline void NzColor::ToCMY(const NzColor& color, float* cyan, float* magenta, float* yellow)
|
||||
{
|
||||
inline void Color::ToCMY(const Color& color, float* cyan, float* magenta, float* yellow)
|
||||
{
|
||||
*cyan = 1.f - color.r/255.f;
|
||||
*magenta = 1.f - color.g/255.f;
|
||||
*yellow = 1.f - color.b/255.f;
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzColor::ToCMYK(const NzColor& color, float* cyan, float* magenta, float* yellow, float* black)
|
||||
{
|
||||
inline void Color::ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black)
|
||||
{
|
||||
float c, m, y;
|
||||
ToCMY(color, &c, &m, &y);
|
||||
|
||||
float k = std::min({1.f, c, m, y});
|
||||
|
||||
if (NzNumberEquals(k, 1.f))
|
||||
if (NumberEquals(k, 1.f))
|
||||
{
|
||||
//Black
|
||||
*cyan = 0.f;
|
||||
|
|
@ -259,10 +263,10 @@ inline void NzColor::ToCMYK(const NzColor& color, float* cyan, float* magenta, f
|
|||
}
|
||||
|
||||
*black = k;
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturation, nzUInt8* lightness)
|
||||
{
|
||||
inline void Color::ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness)
|
||||
{
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
|
@ -274,7 +278,7 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
|
|||
|
||||
float l = (max + min)/2.f;
|
||||
|
||||
if (NzNumberEquals(deltaMax, 0.f))
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSL results from 0 to 1
|
||||
|
|
@ -284,20 +288,20 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
|
|||
{
|
||||
//Chromatic data...
|
||||
if (l < 0.5f)
|
||||
*saturation = static_cast<nzUInt8>(deltaMax/(max+min)*240.f);
|
||||
*saturation = static_cast<UInt8>(deltaMax/(max+min)*240.f);
|
||||
else
|
||||
*saturation = static_cast<nzUInt8>(deltaMax/(2.f-max-min)*240.f);
|
||||
*saturation = static_cast<UInt8>(deltaMax/(2.f-max-min)*240.f);
|
||||
|
||||
*lightness = static_cast<nzUInt8>(l*240.f);
|
||||
*lightness = static_cast<UInt8>(l*240.f);
|
||||
|
||||
float deltaR = ((max - r)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaG = ((max - g)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax;
|
||||
|
||||
float h;
|
||||
if (NzNumberEquals(r, max))
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NzNumberEquals(g, max))
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
|
|
@ -307,12 +311,12 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
|
|||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
|
||||
*hue = static_cast<nzUInt8>(h*240.f);
|
||||
*hue = static_cast<UInt8>(h*240.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzColor::ToHSV(const NzColor& color, float* hue, float* saturation, float* value)
|
||||
{
|
||||
inline void Color::ToHSV(const Color& color, float* hue, float* saturation, float* value)
|
||||
{
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
|
@ -324,7 +328,7 @@ inline void NzColor::ToHSV(const NzColor& color, float* hue, float* saturation,
|
|||
|
||||
*value = max;
|
||||
|
||||
if (NzNumberEquals(deltaMax, 0.f))
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSV results from 0 to 1
|
||||
|
|
@ -341,9 +345,9 @@ inline void NzColor::ToHSV(const NzColor& color, float* hue, float* saturation,
|
|||
|
||||
float h;
|
||||
|
||||
if (NzNumberEquals(r, max))
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NzNumberEquals(g, max))
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
|
|
@ -355,15 +359,15 @@ inline void NzColor::ToHSV(const NzColor& color, float* hue, float* saturation,
|
|||
|
||||
*hue = h*360.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzColor::ToXYZ(const NzColor& color, NzVector3f* vec)
|
||||
{
|
||||
inline void Color::ToXYZ(const Color& color, Vector3f* vec)
|
||||
{
|
||||
return ToXYZ(color, &vec->x, &vec->y, &vec->z);
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzColor::ToXYZ(const NzColor& color, float* x, float* y, float* z)
|
||||
{
|
||||
inline void Color::ToXYZ(const Color& color, float* x, float* y, float* z)
|
||||
{
|
||||
float r = color.r/255.f; //R from 0 to 255
|
||||
float g = color.g/255.f; //G from 0 to 255
|
||||
float b = color.b/255.f; //B from 0 to 255
|
||||
|
|
@ -391,10 +395,10 @@ inline void NzColor::ToXYZ(const NzColor& color, float* x, float* y, float* z)
|
|||
*x = r*0.4124f + g*0.3576f + b*0.1805f;
|
||||
*y = r*0.2126f + g*0.7152f + b*0.0722f;
|
||||
*z = r*0.0193f + g*0.1192f + b*0.9505f;
|
||||
}
|
||||
}
|
||||
|
||||
inline float NzColor::Hue2RGB(float v1, float v2, float vH)
|
||||
{
|
||||
inline float Color::Hue2RGB(float v1, float v2, float vH)
|
||||
{
|
||||
if (vH < 0.f)
|
||||
vH += 1;
|
||||
|
||||
|
|
@ -412,8 +416,9 @@ inline float NzColor::Hue2RGB(float v1, float v2, float vH)
|
|||
|
||||
return v1;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const NzColor& color)
|
||||
inline std::ostream& operator<<(std::ostream& out, const Nz::Color& color)
|
||||
{
|
||||
return out << color.ToString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,25 +8,32 @@
|
|||
#define NAZARA_CONDITIONVARIABLE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
|
||||
class NzConditionVariableImpl;
|
||||
class NzMutex;
|
||||
|
||||
class NAZARA_CORE_API NzConditionVariable : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
class ConditionVariableImpl;
|
||||
class Mutex;
|
||||
|
||||
class NAZARA_CORE_API ConditionVariable
|
||||
{
|
||||
public:
|
||||
NzConditionVariable();
|
||||
~NzConditionVariable();
|
||||
ConditionVariable();
|
||||
ConditionVariable(const ConditionVariable&) = delete;
|
||||
ConditionVariable(ConditionVariable&&) = delete; ///TODO
|
||||
~ConditionVariable();
|
||||
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
|
||||
void Wait(NzMutex* mutex);
|
||||
bool Wait(NzMutex* mutex, nzUInt32 timeout);
|
||||
void Wait(Mutex* mutex);
|
||||
bool Wait(Mutex* mutex, UInt32 timeout);
|
||||
|
||||
ConditionVariable& operator=(const ConditionVariable&) = delete;
|
||||
ConditionVariable& operator=(ConditionVariable&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
NzConditionVariableImpl* m_impl;
|
||||
};
|
||||
ConditionVariableImpl* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_CONDITIONVARIABLE_HPP
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
// Taille du buffer lors d'une lecture complète d'un fichier (ex: Hash)
|
||||
#define NAZARA_CORE_FILE_BUFFERSIZE 4096
|
||||
|
||||
// Incorpore la table Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
|
||||
// Incorpore la table Unicode Character Data (Nécessaires pour faire fonctionner le flag String::HandleUTF8)
|
||||
#define NAZARA_CORE_INCLUDE_UNICODEDATA 0
|
||||
|
||||
// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes)
|
||||
|
|
@ -57,12 +57,12 @@
|
|||
#define NAZARA_CORE_THREADSAFE 1
|
||||
|
||||
// Les classes à protéger des accès concurrentiels
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory
|
||||
#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib
|
||||
#define NAZARA_THREADSAFETY_FILE 1 // NzFile
|
||||
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
|
||||
#define NAZARA_THREADSAFETY_REFCOUNTED 1 // NzRefCounted
|
||||
#define NAZARA_THREADSAFETY_CLOCK 0 // Clock
|
||||
#define NAZARA_THREADSAFETY_DIRECTORY 1 // Directory
|
||||
#define NAZARA_THREADSAFETY_DYNLIB 1 // DynLib
|
||||
#define NAZARA_THREADSAFETY_FILE 1 // File
|
||||
#define NAZARA_THREADSAFETY_LOG 1 // Log
|
||||
#define NAZARA_THREADSAFETY_REFCOUNTED 1 // RefCounted
|
||||
|
||||
// Le nombre de spinlocks à utiliser avec les sections critiques de Windows (0 pour désactiver)
|
||||
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
|
||||
class NAZARA_CORE_API NzCore
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API Core
|
||||
{
|
||||
public:
|
||||
NzCore() = delete;
|
||||
~NzCore() = delete;
|
||||
Core() = delete;
|
||||
~Core() = delete;
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
|
|
@ -24,6 +26,7 @@ class NAZARA_CORE_API NzCore
|
|||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_CORE_HPP
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ NAZARA_CORE_API void operator delete[](void* ptr, const char* file, unsigned int
|
|||
#endif // NAZARA_DEBUG_NEWREDEFINITION_HPP
|
||||
|
||||
#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define delete MemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#define NAZARA_DIRECTORY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
|
@ -26,24 +25,28 @@
|
|||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzDirectoryImpl;
|
||||
|
||||
class NAZARA_CORE_API NzDirectory : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
class DirectoryImpl;
|
||||
|
||||
class NAZARA_CORE_API Directory
|
||||
{
|
||||
public:
|
||||
NzDirectory();
|
||||
NzDirectory(const NzString& dirPath);
|
||||
~NzDirectory();
|
||||
Directory();
|
||||
Directory(const String& dirPath);
|
||||
Directory(const Directory&) = delete;
|
||||
Directory(Directory&&) = delete; ///TODO
|
||||
~Directory();
|
||||
|
||||
void Close();
|
||||
|
||||
bool Exists() const;
|
||||
|
||||
NzString GetPath() const;
|
||||
NzString GetPattern() const;
|
||||
NzString GetResultName() const;
|
||||
NzString GetResultPath() const;
|
||||
nzUInt64 GetResultSize() const;
|
||||
String GetPath() const;
|
||||
String GetPattern() const;
|
||||
String GetResultName() const;
|
||||
String GetResultPath() const;
|
||||
UInt64 GetResultSize() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
bool IsResultDirectory() const;
|
||||
|
|
@ -52,23 +55,27 @@ class NAZARA_CORE_API NzDirectory : NzNonCopyable
|
|||
|
||||
bool Open();
|
||||
|
||||
void SetPath(const NzString& dirPath);
|
||||
void SetPattern(const NzString& pattern);
|
||||
void SetPath(const String& dirPath);
|
||||
void SetPattern(const String& pattern);
|
||||
|
||||
static bool Copy(const NzString& sourcePath, const NzString& destPath);
|
||||
static bool Create(const NzString& dirPath, bool recursive = false);
|
||||
static bool Exists(const NzString& dirPath);
|
||||
static NzString GetCurrent();
|
||||
static bool Copy(const String& sourcePath, const String& destPath);
|
||||
static bool Create(const String& dirPath, bool recursive = false);
|
||||
static bool Exists(const String& dirPath);
|
||||
static String GetCurrent();
|
||||
static const char* GetCurrentFileRelativeToEngine(const char* currentFile);
|
||||
static bool Remove(const NzString& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const NzString& dirPath);
|
||||
static bool Remove(const String& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const String& dirPath);
|
||||
|
||||
Directory& operator=(const Directory&) = delete;
|
||||
Directory& operator=(Directory&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
NzString m_dirPath;
|
||||
NzString m_pattern;
|
||||
NzDirectoryImpl* m_impl;
|
||||
};
|
||||
String m_dirPath;
|
||||
String m_pattern;
|
||||
DirectoryImpl* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_DIRECTORY_HPP
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#define NAZARA_DYNLIB_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
|
@ -27,32 +26,37 @@
|
|||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
using NzDynLibFunc = int (*)(); // Type "générique" de pointeur sur fonction
|
||||
|
||||
class NzDynLibImpl;
|
||||
|
||||
class NAZARA_CORE_API NzDynLib : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzDynLib();
|
||||
NzDynLib(NzDynLib&& lib);
|
||||
~NzDynLib();
|
||||
using DynLibFunc = int (*)(); // Type "générique" de pointeur sur fonction
|
||||
|
||||
NzString GetLastError() const;
|
||||
NzDynLibFunc GetSymbol(const NzString& symbol) const;
|
||||
class DynLibImpl;
|
||||
|
||||
class NAZARA_CORE_API DynLib
|
||||
{
|
||||
public:
|
||||
DynLib();
|
||||
DynLib(const DynLib&) = delete;
|
||||
DynLib(DynLib&& lib);
|
||||
~DynLib();
|
||||
|
||||
String GetLastError() const;
|
||||
DynLibFunc GetSymbol(const String& symbol) const;
|
||||
|
||||
bool IsLoaded() const;
|
||||
|
||||
bool Load(const NzString& libraryPath);
|
||||
bool Load(const String& libraryPath);
|
||||
void Unload();
|
||||
|
||||
NzDynLib& operator=(NzDynLib&& lib);
|
||||
DynLib& operator=(const DynLib&) = delete;
|
||||
DynLib& operator=(DynLib&& lib);
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
mutable NzString m_lastError;
|
||||
NzDynLibImpl* m_impl;
|
||||
mutable String m_lastError;
|
||||
DynLibImpl* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_DYNLIB_HPP
|
||||
|
|
|
|||
|
|
@ -25,8 +25,11 @@
|
|||
#error You cannot define both NAZARA_BIG_ENDIAN and NAZARA_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
inline void NzByteSwap(void* buffer, unsigned int size);
|
||||
inline nzEndianness NzGetPlatformEndianness();
|
||||
namespace Nz
|
||||
{
|
||||
inline constexpr Endianness GetPlatformEndianness();
|
||||
inline void SwapBytes(void* buffer, unsigned int size);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Endianness.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,23 +5,26 @@
|
|||
#include <algorithm>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline void NzByteSwap(void* buffer, unsigned int size)
|
||||
namespace Nz
|
||||
{
|
||||
nzUInt8* bytes = reinterpret_cast<nzUInt8*>(buffer);
|
||||
inline constexpr Endianness GetPlatformEndianness()
|
||||
{
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
return Endianness_BigEndian;
|
||||
#elif defined(NAZARA_LITTLE_ENDIAN)
|
||||
return Endianness_LittleEndian;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void SwapBytes(void* buffer, unsigned int size)
|
||||
{
|
||||
UInt8* bytes = reinterpret_cast<UInt8*>(buffer);
|
||||
unsigned int i = 0;
|
||||
unsigned int j = size-1;
|
||||
|
||||
while (i < j)
|
||||
std::swap(bytes[i++], bytes[j--]);
|
||||
}
|
||||
|
||||
inline nzEndianness NzGetPlatformEndianness()
|
||||
{
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
return nzEndianness_BigEndian;
|
||||
#elif defined(NAZARA_LITTLE_ENDIAN)
|
||||
return nzEndianness_LittleEndian;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -7,182 +7,187 @@
|
|||
#ifndef NAZARA_ENUMS_CORE_HPP
|
||||
#define NAZARA_ENUMS_CORE_HPP
|
||||
|
||||
enum nzCoordSys
|
||||
namespace Nz
|
||||
{
|
||||
nzCoordSys_Global,
|
||||
nzCoordSys_Local,
|
||||
enum CoordSys
|
||||
{
|
||||
CoordSys_Global,
|
||||
CoordSys_Local,
|
||||
|
||||
nzCoordSys_Max = nzCoordSys_Local
|
||||
};
|
||||
CoordSys_Max = CoordSys_Local
|
||||
};
|
||||
|
||||
enum nzCursorPosition
|
||||
{
|
||||
nzCursorPosition_AtBegin, // Début du fichier
|
||||
nzCursorPosition_AtCurrent, // Position du pointeur
|
||||
nzCursorPosition_AtEnd, // Fin du fichier
|
||||
enum CursorPosition
|
||||
{
|
||||
CursorPosition_AtBegin, // Début du fichier
|
||||
CursorPosition_AtCurrent, // Position du pointeur
|
||||
CursorPosition_AtEnd, // Fin du fichier
|
||||
|
||||
nzCursorPosition_Max = nzCursorPosition_AtEnd
|
||||
};
|
||||
CursorPosition_Max = CursorPosition_AtEnd
|
||||
};
|
||||
|
||||
enum nzEndianness
|
||||
{
|
||||
nzEndianness_Unknown = -1,
|
||||
enum Endianness
|
||||
{
|
||||
Endianness_Unknown = -1,
|
||||
|
||||
nzEndianness_BigEndian,
|
||||
nzEndianness_LittleEndian,
|
||||
Endianness_BigEndian,
|
||||
Endianness_LittleEndian,
|
||||
|
||||
nzEndianness_Max = nzEndianness_LittleEndian
|
||||
};
|
||||
Endianness_Max = Endianness_LittleEndian
|
||||
};
|
||||
|
||||
enum nzErrorFlag
|
||||
{
|
||||
nzErrorFlag_None = 0,
|
||||
enum ErrorFlag
|
||||
{
|
||||
ErrorFlag_None = 0,
|
||||
|
||||
nzErrorFlag_Silent = 0x1,
|
||||
nzErrorFlag_SilentDisabled = 0x2,
|
||||
nzErrorFlag_ThrowException = 0x4,
|
||||
nzErrorFlag_ThrowExceptionDisabled = 0x8,
|
||||
ErrorFlag_Silent = 0x1,
|
||||
ErrorFlag_SilentDisabled = 0x2,
|
||||
ErrorFlag_ThrowException = 0x4,
|
||||
ErrorFlag_ThrowExceptionDisabled = 0x8,
|
||||
|
||||
nzErrorFlag_Max = nzErrorFlag_ThrowExceptionDisabled*2-1
|
||||
};
|
||||
ErrorFlag_Max = ErrorFlag_ThrowExceptionDisabled*2-1
|
||||
};
|
||||
|
||||
enum nzErrorType
|
||||
{
|
||||
nzErrorType_AssertFailed,
|
||||
nzErrorType_Internal,
|
||||
nzErrorType_Normal,
|
||||
nzErrorType_Warning,
|
||||
enum ErrorType
|
||||
{
|
||||
ErrorType_AssertFailed,
|
||||
ErrorType_Internal,
|
||||
ErrorType_Normal,
|
||||
ErrorType_Warning,
|
||||
|
||||
nzErrorType_Max = nzErrorType_Warning
|
||||
};
|
||||
ErrorType_Max = ErrorType_Warning
|
||||
};
|
||||
|
||||
enum nzHash
|
||||
{
|
||||
nzHash_CRC32,
|
||||
nzHash_Fletcher16,
|
||||
nzHash_MD5,
|
||||
nzHash_SHA1,
|
||||
nzHash_SHA224,
|
||||
nzHash_SHA256,
|
||||
nzHash_SHA384,
|
||||
nzHash_SHA512,
|
||||
nzHash_Whirlpool,
|
||||
enum HashType
|
||||
{
|
||||
HashType_CRC32,
|
||||
HashType_Fletcher16,
|
||||
HashType_MD5,
|
||||
HashType_SHA1,
|
||||
HashType_SHA224,
|
||||
HashType_SHA256,
|
||||
HashType_SHA384,
|
||||
HashType_SHA512,
|
||||
HashType_Whirlpool,
|
||||
|
||||
nzHash_Max = nzHash_Whirlpool
|
||||
};
|
||||
HashType_Max = HashType_Whirlpool
|
||||
};
|
||||
|
||||
enum nzOpenModeFlags
|
||||
{
|
||||
nzOpenMode_Current = 0x00, // Utilise le mode d'ouverture actuel
|
||||
enum OpenModeFlags
|
||||
{
|
||||
OpenMode_NotOpen = 0x00, // Utilise le mode d'ouverture actuel
|
||||
|
||||
nzOpenMode_Append = 0x01, // Empêche l'écriture sur la partie déjà existante et met le curseur à la fin
|
||||
nzOpenMode_Lock = 0x02, // Empêche le fichier d'être modifié tant qu'il est ouvert
|
||||
nzOpenMode_ReadOnly = 0x04, // Ouvre uniquement en lecture
|
||||
nzOpenMode_ReadWrite = 0x08, // Ouvre en lecture/écriture
|
||||
nzOpenMode_Text = 0x10, // Ouvre en mode texte
|
||||
nzOpenMode_Truncate = 0x20, // Créé le fichier s'il n'existe pas et le vide s'il existe
|
||||
nzOpenMode_WriteOnly = 0x40, // Ouvre uniquement en écriture, créé le fichier s'il n'existe pas
|
||||
OpenMode_Append = 0x01, // Empêche l'écriture sur la partie déjà existante et met le curseur à la fin
|
||||
OpenMode_Lock = 0x02, // Empêche le fichier d'être modifié tant qu'il est ouvert
|
||||
OpenMode_ReadOnly = 0x04, // Ouvre uniquement en lecture
|
||||
OpenMode_Text = 0x10, // Ouvre en mode texte
|
||||
OpenMode_Truncate = 0x20, // Créé le fichier s'il n'existe pas et le vide s'il existe
|
||||
OpenMode_WriteOnly = 0x40, // Ouvre uniquement en écriture, créé le fichier s'il n'existe pas
|
||||
|
||||
nzOpenMode_Max = nzOpenMode_WriteOnly
|
||||
};
|
||||
OpenMode_ReadWrite = OpenMode_ReadOnly | OpenMode_WriteOnly, // Ouvre en lecture/écriture
|
||||
|
||||
enum nzParameterType
|
||||
{
|
||||
nzParameterType_Boolean,
|
||||
nzParameterType_Float,
|
||||
nzParameterType_Integer,
|
||||
nzParameterType_None,
|
||||
nzParameterType_Pointer,
|
||||
nzParameterType_String,
|
||||
nzParameterType_Userdata,
|
||||
OpenMode_Max = OpenMode_WriteOnly
|
||||
};
|
||||
|
||||
nzParameterType_Max = nzParameterType_Userdata
|
||||
};
|
||||
enum ParameterType
|
||||
{
|
||||
ParameterType_Boolean,
|
||||
ParameterType_Float,
|
||||
ParameterType_Integer,
|
||||
ParameterType_None,
|
||||
ParameterType_Pointer,
|
||||
ParameterType_String,
|
||||
ParameterType_Userdata,
|
||||
|
||||
enum nzPlugin
|
||||
{
|
||||
nzPlugin_Assimp,
|
||||
nzPlugin_FreeType
|
||||
};
|
||||
ParameterType_Max = ParameterType_Userdata
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_Box,
|
||||
nzPrimitiveType_Cone,
|
||||
nzPrimitiveType_Plane,
|
||||
nzPrimitiveType_Sphere,
|
||||
enum Plugin
|
||||
{
|
||||
Plugin_Assimp,
|
||||
Plugin_FreeType
|
||||
};
|
||||
|
||||
nzPrimitiveType_Max = nzPrimitiveType_Sphere
|
||||
};
|
||||
enum PrimitiveType
|
||||
{
|
||||
PrimitiveType_Box,
|
||||
PrimitiveType_Cone,
|
||||
PrimitiveType_Plane,
|
||||
PrimitiveType_Sphere,
|
||||
|
||||
enum nzProcessorCap
|
||||
{
|
||||
nzProcessorCap_x64,
|
||||
nzProcessorCap_AVX,
|
||||
nzProcessorCap_FMA3,
|
||||
nzProcessorCap_FMA4,
|
||||
nzProcessorCap_MMX,
|
||||
nzProcessorCap_XOP,
|
||||
nzProcessorCap_SSE,
|
||||
nzProcessorCap_SSE2,
|
||||
nzProcessorCap_SSE3,
|
||||
nzProcessorCap_SSSE3,
|
||||
nzProcessorCap_SSE41,
|
||||
nzProcessorCap_SSE42,
|
||||
nzProcessorCap_SSE4a,
|
||||
PrimitiveType_Max = PrimitiveType_Sphere
|
||||
};
|
||||
|
||||
nzProcessorCap_Max = nzProcessorCap_SSE4a
|
||||
};
|
||||
enum ProcessorCap
|
||||
{
|
||||
ProcessorCap_x64,
|
||||
ProcessorCap_AVX,
|
||||
ProcessorCap_FMA3,
|
||||
ProcessorCap_FMA4,
|
||||
ProcessorCap_MMX,
|
||||
ProcessorCap_XOP,
|
||||
ProcessorCap_SSE,
|
||||
ProcessorCap_SSE2,
|
||||
ProcessorCap_SSE3,
|
||||
ProcessorCap_SSSE3,
|
||||
ProcessorCap_SSE41,
|
||||
ProcessorCap_SSE42,
|
||||
ProcessorCap_SSE4a,
|
||||
|
||||
enum nzProcessorVendor
|
||||
{
|
||||
nzProcessorVendor_Unknown = -1,
|
||||
ProcessorCap_Max = ProcessorCap_SSE4a
|
||||
};
|
||||
|
||||
nzProcessorVendor_AMD,
|
||||
nzProcessorVendor_Centaur,
|
||||
nzProcessorVendor_Cyrix,
|
||||
nzProcessorVendor_Intel,
|
||||
nzProcessorVendor_KVM,
|
||||
nzProcessorVendor_HyperV,
|
||||
nzProcessorVendor_NSC,
|
||||
nzProcessorVendor_NexGen,
|
||||
nzProcessorVendor_Rise,
|
||||
nzProcessorVendor_SIS,
|
||||
nzProcessorVendor_Transmeta,
|
||||
nzProcessorVendor_UMC,
|
||||
nzProcessorVendor_VIA,
|
||||
nzProcessorVendor_VMware,
|
||||
nzProcessorVendor_Vortex,
|
||||
nzProcessorVendor_XenHVM,
|
||||
enum ProcessorVendor
|
||||
{
|
||||
ProcessorVendor_Unknown = -1,
|
||||
|
||||
nzProcessorVendor_Max = nzProcessorVendor_XenHVM
|
||||
};
|
||||
ProcessorVendor_AMD,
|
||||
ProcessorVendor_Centaur,
|
||||
ProcessorVendor_Cyrix,
|
||||
ProcessorVendor_Intel,
|
||||
ProcessorVendor_KVM,
|
||||
ProcessorVendor_HyperV,
|
||||
ProcessorVendor_NSC,
|
||||
ProcessorVendor_NexGen,
|
||||
ProcessorVendor_Rise,
|
||||
ProcessorVendor_SIS,
|
||||
ProcessorVendor_Transmeta,
|
||||
ProcessorVendor_UMC,
|
||||
ProcessorVendor_VIA,
|
||||
ProcessorVendor_VMware,
|
||||
ProcessorVendor_Vortex,
|
||||
ProcessorVendor_XenHVM,
|
||||
|
||||
enum nzSphereType
|
||||
{
|
||||
nzSphereType_Cubic,
|
||||
nzSphereType_Ico,
|
||||
nzSphereType_UV,
|
||||
ProcessorVendor_Max = ProcessorVendor_XenHVM
|
||||
};
|
||||
|
||||
nzSphereType_Max = nzSphereType_UV
|
||||
};
|
||||
enum SphereType
|
||||
{
|
||||
SphereType_Cubic,
|
||||
SphereType_Ico,
|
||||
SphereType_UV,
|
||||
|
||||
enum nzStreamOptionFlags
|
||||
{
|
||||
nzStreamOption_None = 0,
|
||||
SphereType_Max = SphereType_UV
|
||||
};
|
||||
|
||||
nzStreamOption_Text = 0x1,
|
||||
enum StreamOptionFlags
|
||||
{
|
||||
StreamOption_None = 0,
|
||||
|
||||
nzStreamOption_Max = nzStreamOption_Text*2-1
|
||||
};
|
||||
StreamOption_Sequential = 0x1,
|
||||
StreamOption_Text = 0x2,
|
||||
|
||||
enum nzTernary
|
||||
{
|
||||
nzTernary_False,
|
||||
nzTernary_True,
|
||||
nzTernary_Unknown,
|
||||
StreamOption_Max = StreamOption_Text*2-1
|
||||
};
|
||||
|
||||
nzTernary_Max = nzTernary_Unknown
|
||||
};
|
||||
enum Ternary
|
||||
{
|
||||
Ternary_False,
|
||||
Ternary_True,
|
||||
Ternary_Unknown,
|
||||
|
||||
Ternary_Max = Ternary_Unknown
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_CORE_HPP
|
||||
|
|
|
|||
|
|
@ -14,37 +14,40 @@
|
|||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
||||
#define NazaraAssert(a, err) if (!(a)) NzError::Error(nzErrorType_AssertFailed, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraAssert(a, err) if (!(a)) Nz::Error::Trigger(Nz::ErrorType_AssertFailed, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#else
|
||||
#define NazaraAssert(a, err)
|
||||
#define NazaraAssert(a, err) for (;;) break
|
||||
#endif
|
||||
|
||||
#define NazaraError(err) NzError::Error(nzErrorType_Normal, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraInternalError(err) NzError::Error(nzErrorType_Internal, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraWarning(err) NzError::Error(nzErrorType_Warning, err, __LINE__, NzDirectory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraError(err) Nz::Error::Trigger(Nz::ErrorType_Normal, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraInternalError(err) Nz::Error::Trigger(Nz::ErrorType_Internal, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
#define NazaraWarning(err) Nz::Error::Trigger(Nz::ErrorType_Warning, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
||||
|
||||
class NAZARA_CORE_API NzError
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API Error
|
||||
{
|
||||
public:
|
||||
NzError() = delete;
|
||||
~NzError() = delete;
|
||||
Error() = delete;
|
||||
~Error() = delete;
|
||||
|
||||
static void Error(nzErrorType type, const NzString& error);
|
||||
static void Error(nzErrorType type, const NzString& error, unsigned int line, const char* file, const char* function);
|
||||
|
||||
static nzUInt32 GetFlags();
|
||||
static NzString GetLastError(const char** file = nullptr, unsigned int* line = nullptr, const char** function = nullptr);
|
||||
static UInt32 GetFlags();
|
||||
static String GetLastError(const char** file = nullptr, unsigned int* line = nullptr, const char** function = nullptr);
|
||||
static unsigned int GetLastSystemErrorCode();
|
||||
static NzString GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
|
||||
static String GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
|
||||
|
||||
static void SetFlags(nzUInt32 flags);
|
||||
static void SetFlags(UInt32 flags);
|
||||
|
||||
static void Trigger(ErrorType type, const String& error);
|
||||
static void Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function);
|
||||
|
||||
private:
|
||||
static nzUInt32 s_flags;
|
||||
static NzString s_lastError;
|
||||
static UInt32 s_flags;
|
||||
static String s_lastError;
|
||||
static const char* s_lastErrorFunction;
|
||||
static const char* s_lastErrorFile;
|
||||
static unsigned int s_lastErrorLine;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ERROR_HPP
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue