Merge branch 'NDK-Refactor' into NDK
Conflicts: examples/HardwareInfo/main.cpp include/Nazara/Renderer/Enums.hpp include/Nazara/Renderer/GpuQuery.hpp include/Nazara/Renderer/OpenGL.hpp include/Nazara/Renderer/RenderBuffer.hpp include/Nazara/Renderer/RenderTexture.hpp include/Nazara/Renderer/Texture.hpp src/Nazara/Graphics/AbstractRenderTechnique.cpp src/Nazara/Graphics/DeferredRenderTechnique.cpp src/Nazara/Graphics/Material.cpp src/Nazara/Graphics/SkyboxBackground.cpp src/Nazara/Renderer/GpuQuery.cpp src/Nazara/Renderer/OpenGL.cpp src/Nazara/Renderer/RenderBuffer.cpp src/Nazara/Renderer/RenderTexture.cpp src/Nazara/Renderer/Renderer.cpp src/Nazara/Renderer/Shader.cpp src/Nazara/Renderer/ShaderStage.cpp src/Nazara/Renderer/Texture.cpp Former-commit-id: 2f1c7e9f9766f59ab83d9405856a1898ac4ab48f
This commit is contained in:
commit
eaf1bb3601
|
|
@ -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,20 +138,20 @@ 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)
|
||||
|
|
@ -160,14 +160,14 @@ namespace Ndk
|
|||
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 +175,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 +187,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);
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Ndk
|
|||
Attach(r.renderable);
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
|
||||
inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const
|
||||
{
|
||||
EnsureTransformMatrixUpdate();
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ namespace Ndk
|
|||
}
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::Attach(NzInstancedRenderableRef renderable)
|
||||
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable)
|
||||
{
|
||||
m_renderables.emplace_back(m_transformMatrix);
|
||||
Renderable& r = m_renderables.back();
|
||||
|
|
|
|||
|
|
@ -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() << ')';
|
||||
|
|
@ -260,9 +260,9 @@ namespace Ndk
|
|||
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<Ndk::EntityHandle>
|
||||
{
|
||||
template<>
|
||||
struct hash<Ndk::EntityHandle>
|
||||
{
|
||||
size_t operator()(const Ndk::EntityHandle& handle) const
|
||||
{
|
||||
// Hasher le pointeur fonctionnerait jusqu'à ce que l'entité soit mise à jour et déplacée
|
||||
|
|
@ -271,9 +271,9 @@ namespace std
|
|||
|
||||
return hash<Ndk::EntityId>()(id);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
inline void swap(Ndk::EntityHandle& lhs, Ndk::EntityHandle& rhs)
|
||||
inline void swap(Ndk::EntityHandle& lhs, Ndk::EntityHandle& rhs)
|
||||
{
|
||||
lhs.Swap(rhs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,16 +25,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;
|
||||
|
||||
|
|
@ -48,9 +48,9 @@ namespace Ndk
|
|||
EntityList m_cameras;
|
||||
EntityList m_drawables;
|
||||
EntityList m_lights;
|
||||
NzBackgroundRef m_background;
|
||||
NzForwardRenderTechnique m_renderTechnique;
|
||||
NzMatrix4f m_coordinateSystemMatrix;
|
||||
Nz::BackgroundRef m_background;
|
||||
Nz::ForwardRenderTechnique m_renderTechnique;
|
||||
Nz::Matrix4f m_coordinateSystemMatrix;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ 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)
|
||||
return false; // Au moins un component requis n'est pas présent
|
||||
m_filterResult.PerformsAND(m_requiredComponents, components);
|
||||
if (m_filterResult != m_requiredComponents)
|
||||
return false; // Au moins un component requis n'est pas présent
|
||||
|
||||
m_filterResult.PerformsAND(m_excludedComponents, components);
|
||||
if (m_filterResult.TestAny())
|
||||
return false; // Au moins un component exclu est présent
|
||||
m_filterResult.PerformsAND(m_excludedComponents, components);
|
||||
if (m_filterResult.TestAny())
|
||||
return false; // Au moins un component exclu est présent
|
||||
|
||||
// Si nous avons une liste de composants nécessaires
|
||||
if (m_requiredAnyComponents.TestAny())
|
||||
|
|
@ -34,7 +34,7 @@ namespace Ndk
|
|||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseSystem::OnEntityAdded(Entity* entity)
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,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);
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ namespace Ndk
|
|||
CameraComponent& camComponent = camera->GetComponent<CameraComponent>();
|
||||
camComponent.ApplyView();
|
||||
|
||||
NzAbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
|
||||
Nz::AbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
|
||||
renderQueue->Clear();
|
||||
|
||||
//TODO: Culling
|
||||
|
|
@ -91,11 +91,11 @@ namespace Ndk
|
|||
NodeComponent& drawableNode = light->GetComponent<NodeComponent>();
|
||||
|
||||
///TODO: Cache somehow?
|
||||
lightComponent.AddToRenderQueue(renderQueue, NzMatrix4f::ConcatenateAffine(m_coordinateSystemMatrix, drawableNode.GetTransformMatrix()));
|
||||
lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, drawableNode.GetTransformMatrix()));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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,63 +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, "-Mode debug", NzOpenGL::IsSupported(nzOpenGLExtension_DebugOutput));
|
||||
printCap(oss, "-Separate shader objects", NzOpenGL::IsSupported(nzOpenGLExtension_SeparateShaderObjects));
|
||||
printCap(oss, "-Texture storage", NzOpenGL::IsSupported(nzOpenGLExtension_TextureStorage));
|
||||
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;
|
||||
|
|
@ -94,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;
|
||||
|
|
@ -111,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;
|
||||
Initializer<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/");
|
||||
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<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 ?
|
||||
String path = resourceDirectory.GetResultName();
|
||||
String ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne
|
||||
if (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;
|
||||
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 AnimationType_Skeletal:
|
||||
std::cout << "This is a skeletal-animated mesh" << std::endl;
|
||||
break;
|
||||
|
||||
case nzAnimationType_Static:
|
||||
case 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() == AnimationType_Skeletal)
|
||||
{
|
||||
const NzSkeleton* skeleton = mesh.GetSkeleton();
|
||||
const 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 Joint* joint = skeleton->GetJoint(i);
|
||||
std::cout << "\t" << (i+1) << ": " << joint->GetName();
|
||||
|
||||
const NzJoint* parent = static_cast<const NzJoint*>(joint->GetParent());
|
||||
const Joint* parent = static_cast<const Joint*>(joint->GetParent());
|
||||
if (parent)
|
||||
std::cout << " (Parent: " << parent->GetName() << ')';
|
||||
|
||||
|
|
@ -119,10 +119,10 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
NzString animationPath = mesh.GetAnimation();
|
||||
String animationPath = mesh.GetAnimation();
|
||||
if (!animationPath.IsEmpty())
|
||||
{
|
||||
NzAnimation animation;
|
||||
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 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();
|
||||
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,21 +5,24 @@
|
|||
#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
|
||||
{
|
||||
///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_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
|
||||
for (unsigned int i = 0; i < frameCount; ++i)
|
||||
template<typename T>
|
||||
void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
|
||||
{
|
||||
Biggest acc = Biggest(0);
|
||||
for (unsigned int j = 0; j < channelCount; ++j)
|
||||
acc += input[i*channelCount + j];
|
||||
///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, UInt64, Int64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
|
||||
output[i] = static_cast<T>(acc/channelCount);
|
||||
for (unsigned int i = 0; i < frameCount; ++i)
|
||||
{
|
||||
Biggest acc = Biggest(0);
|
||||
for (unsigned int j = 0; j < channelCount; ++j)
|
||||
acc += input[i*channelCount + j];
|
||||
|
||||
output[i] = static_cast<T>(acc / channelCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,41 +14,44 @@
|
|||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
class NAZARA_AUDIO_API NzAudio
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzAudio() = delete;
|
||||
~NzAudio() = delete;
|
||||
class NAZARA_AUDIO_API Audio
|
||||
{
|
||||
public:
|
||||
Audio() = delete;
|
||||
~Audio() = delete;
|
||||
|
||||
static nzAudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
static float GetDopplerFactor();
|
||||
static float GetGlobalVolume();
|
||||
static NzVector3f GetListenerDirection();
|
||||
static NzVector3f GetListenerPosition();
|
||||
static NzQuaternionf GetListenerRotation();
|
||||
static NzVector3f GetListenerVelocity();
|
||||
static float GetSpeedOfSound();
|
||||
static AudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
static float GetDopplerFactor();
|
||||
static float GetGlobalVolume();
|
||||
static Vector3f GetListenerDirection();
|
||||
static Vector3f GetListenerPosition();
|
||||
static Quaternionf GetListenerRotation();
|
||||
static Vector3f GetListenerVelocity();
|
||||
static float GetSpeedOfSound();
|
||||
|
||||
static bool Initialize();
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsFormatSupported(nzAudioFormat format);
|
||||
static bool IsInitialized();
|
||||
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(float dirX, float dirY, float dirZ);
|
||||
static void SetListenerPosition(const NzVector3f& position);
|
||||
static void SetListenerPosition(float x, float y, float z);
|
||||
static void SetListenerRotation(const NzQuaternionf& rotation);
|
||||
static void SetListenerVelocity(const NzVector3f& velocity);
|
||||
static void SetListenerVelocity(float velX, float velY, float velZ);
|
||||
static void SetSpeedOfSound(float speed);
|
||||
static void SetDopplerFactor(float dopplerFactor);
|
||||
static void SetGlobalVolume(float volume);
|
||||
static void SetListenerDirection(const Vector3f& direction);
|
||||
static void SetListenerDirection(float dirX, float dirY, float dirZ);
|
||||
static void SetListenerPosition(const Vector3f& position);
|
||||
static void SetListenerPosition(float x, float y, float z);
|
||||
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);
|
||||
|
||||
static void Uninitialize();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_AUDIO_HPP
|
||||
|
|
|
|||
|
|
@ -7,26 +7,30 @@
|
|||
#ifndef NAZARA_ENUMS_HPP
|
||||
#define NAZARA_ENUMS_HPP
|
||||
|
||||
enum nzAudioFormat
|
||||
namespace Nz
|
||||
{
|
||||
nzAudioFormat_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,
|
||||
enum AudioFormat
|
||||
{
|
||||
AudioFormat_Unknown = -1,
|
||||
|
||||
nzAudioFormat_Max = nzAudioFormat_7_1
|
||||
};
|
||||
// La valeur entière est le nombre de canaux possédés par ce format
|
||||
AudioFormat_Mono = 1,
|
||||
AudioFormat_Stereo = 2,
|
||||
AudioFormat_Quad = 4,
|
||||
AudioFormat_5_1 = 6,
|
||||
AudioFormat_6_1 = 7,
|
||||
AudioFormat_7_1 = 8,
|
||||
|
||||
enum nzSoundStatus
|
||||
{
|
||||
nzSoundStatus_Playing,
|
||||
nzSoundStatus_Paused,
|
||||
nzSoundStatus_Stopped
|
||||
};
|
||||
AudioFormat_Max = AudioFormat_7_1
|
||||
};
|
||||
|
||||
enum SoundStatus
|
||||
{
|
||||
SoundStatus_Playing,
|
||||
SoundStatus_Paused,
|
||||
SoundStatus_Stopped
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_HPP
|
||||
|
|
|
|||
|
|
@ -13,60 +13,68 @@
|
|||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
|
||||
struct NzMusicParams
|
||||
namespace Nz
|
||||
{
|
||||
bool forceMono = false;
|
||||
struct MusicParams
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
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();
|
||||
public:
|
||||
Music() = default;
|
||||
Music(const Music&) = delete;
|
||||
Music(Music&&) = delete; ///TODO
|
||||
~Music();
|
||||
|
||||
bool Create(NzSoundStream* soundStream);
|
||||
void Destroy();
|
||||
bool Create(SoundStream* soundStream);
|
||||
void Destroy();
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
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 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(InputStream& stream, const MusicParams& params = MusicParams());
|
||||
|
||||
void Pause();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Play();
|
||||
|
||||
void SetPlayingOffset(nzUInt32 offset);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
NzMusicImpl* m_impl = nullptr;
|
||||
Music& operator=(const Music&) = delete;
|
||||
Music& operator=(Music&&) = delete; ///TODO
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
private:
|
||||
MusicImpl* m_impl = nullptr;
|
||||
|
||||
static NzMusicLoader::LoaderList s_loaders;
|
||||
};
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
static NzOpenALFunc GetEntry(const NzString& entryPoint);
|
||||
static NzString GetRendererName();
|
||||
static NzString GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
using OpenALFunc = void(*)();
|
||||
|
||||
static bool Initialize(bool openDevice = true);
|
||||
class NAZARA_AUDIO_API OpenAL
|
||||
{
|
||||
public:
|
||||
static OpenALFunc GetEntry(const String& entryPoint);
|
||||
static String GetRendererName();
|
||||
static String GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
|
||||
static bool IsInitialized();
|
||||
static bool Initialize(bool openDevice = true);
|
||||
|
||||
static unsigned int QueryInputDevices(std::vector<NzString>& devices);
|
||||
static unsigned int QueryOutputDevices(std::vector<NzString>& devices);
|
||||
static bool IsInitialized();
|
||||
|
||||
static bool SetDevice(const NzString& deviceName);
|
||||
static unsigned int QueryInputDevices(std::vector<String>& devices);
|
||||
static unsigned int QueryOutputDevices(std::vector<String>& devices);
|
||||
|
||||
static void Uninitialize();
|
||||
static bool SetDevice(const String& deviceName);
|
||||
|
||||
static ALenum AudioFormat[nzAudioFormat_Max+1];
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static void CloseDevice();
|
||||
static bool OpenDevice();
|
||||
static NzOpenALFunc LoadEntry(const char* name, bool throwException = false);
|
||||
};
|
||||
static ALenum AudioFormat[AudioFormat_Max + 1];
|
||||
|
||||
private:
|
||||
static void CloseDevice();
|
||||
static bool OpenDevice();
|
||||
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
|
||||
{
|
||||
public:
|
||||
NzSound() = default;
|
||||
NzSound(const NzSoundBuffer* soundBuffer);
|
||||
NzSound(const NzSound& sound);
|
||||
~NzSound();
|
||||
class NAZARA_AUDIO_API Sound : public SoundEmitter
|
||||
{
|
||||
public:
|
||||
Sound() = default;
|
||||
Sound(const SoundBuffer* soundBuffer);
|
||||
Sound(const Sound& sound);
|
||||
Sound(Sound&&) = default;
|
||||
~Sound();
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
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 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(InputStream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
void Pause();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Play();
|
||||
|
||||
void SetBuffer(const NzSoundBuffer* buffer);
|
||||
void SetPlayingOffset(nzUInt32 offset);
|
||||
void SetBuffer(const SoundBuffer* buffer);
|
||||
void SetPlayingOffset(UInt32 offset);
|
||||
|
||||
void Stop();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
NzSoundBufferConstRef m_buffer;
|
||||
};
|
||||
Sound& operator=(const Sound&) = delete; ///TODO?
|
||||
Sound& operator=(Sound&&) = default;
|
||||
|
||||
private:
|
||||
SoundBufferConstRef m_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SOUND_HPP
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#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>
|
||||
|
|
@ -20,72 +19,80 @@
|
|||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
|
||||
struct NzSoundBufferParams
|
||||
namespace Nz
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzSound;
|
||||
class NzSoundBuffer;
|
||||
|
||||
using NzSoundBufferConstRef = NzObjectRef<const NzSoundBuffer>;
|
||||
using NzSoundBufferLibrary = NzObjectLibrary<NzSoundBuffer>;
|
||||
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferManager = NzResourceManager<NzSoundBuffer, NzSoundBufferParams>;
|
||||
using NzSoundBufferRef = NzObjectRef<NzSoundBuffer>;
|
||||
|
||||
struct NzSoundBufferImpl;
|
||||
|
||||
class NAZARA_AUDIO_API NzSoundBuffer : public NzRefCounted, public NzResource, NzNonCopyable
|
||||
{
|
||||
friend NzSound;
|
||||
friend NzSoundBufferLibrary;
|
||||
friend NzSoundBufferLoader;
|
||||
friend NzSoundBufferManager;
|
||||
friend class NzAudio;
|
||||
|
||||
public:
|
||||
NzSoundBuffer() = default;
|
||||
NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples);
|
||||
~NzSoundBuffer();
|
||||
|
||||
bool Create(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples);
|
||||
void Destroy();
|
||||
|
||||
nzUInt32 GetDuration() const;
|
||||
nzAudioFormat GetFormat() const;
|
||||
const nzInt16* GetSamples() const;
|
||||
unsigned int GetSampleCount() const;
|
||||
unsigned int GetSampleRate() const;
|
||||
struct SoundBufferParams
|
||||
{
|
||||
bool forceMono = false;
|
||||
|
||||
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());
|
||||
class Sound;
|
||||
class SoundBuffer;
|
||||
|
||||
static bool IsFormatSupported(nzAudioFormat format);
|
||||
template<typename... Args> static NzSoundBufferRef New(Args&&... args);
|
||||
using SoundBufferConstRef = ObjectRef<const SoundBuffer>;
|
||||
using SoundBufferLibrary = ObjectLibrary<SoundBuffer>;
|
||||
using SoundBufferLoader = ResourceLoader<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferManager = ResourceManager<SoundBuffer, SoundBufferParams>;
|
||||
using SoundBufferRef = ObjectRef<SoundBuffer>;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSoundBufferDestroy, const NzSoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const NzSoundBuffer* /*soundBuffer*/);
|
||||
struct SoundBufferImpl;
|
||||
|
||||
private:
|
||||
unsigned int GetOpenALBuffer() const;
|
||||
class NAZARA_AUDIO_API SoundBuffer : public RefCounted, public Resource
|
||||
{
|
||||
friend Sound;
|
||||
friend SoundBufferLibrary;
|
||||
friend SoundBufferLoader;
|
||||
friend SoundBufferManager;
|
||||
friend class Audio;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
public:
|
||||
SoundBuffer() = default;
|
||||
SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
SoundBuffer(const SoundBuffer&) = delete;
|
||||
SoundBuffer(SoundBuffer&&) = delete;
|
||||
~SoundBuffer();
|
||||
|
||||
NzSoundBufferImpl* m_impl = nullptr;
|
||||
bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
void Destroy();
|
||||
|
||||
static NzSoundBufferLibrary::LibraryMap s_library;
|
||||
static NzSoundBufferLoader::LoaderList s_loaders;
|
||||
static NzSoundBufferManager::ManagerMap s_managerMap;
|
||||
static NzSoundBufferManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
const Int16* GetSamples() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams());
|
||||
bool LoadFromStream(InputStream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
|
||||
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 SoundBuffer* /*soundBuffer*/);
|
||||
NazaraSignal(OnSoundBufferRelease, const SoundBuffer* /*soundBuffer*/);
|
||||
|
||||
private:
|
||||
unsigned int GetOpenALBuffer() const;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
SoundBufferImpl* m_impl = nullptr;
|
||||
|
||||
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)...));
|
||||
object->SetPersistent(false);
|
||||
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();
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -11,53 +11,58 @@
|
|||
#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
|
||||
{
|
||||
public:
|
||||
virtual ~NzSoundEmitter();
|
||||
class NAZARA_AUDIO_API SoundEmitter
|
||||
{
|
||||
public:
|
||||
virtual ~SoundEmitter();
|
||||
|
||||
virtual void EnableLooping(bool loop) = 0;
|
||||
void EnableSpatialization(bool spatialization);
|
||||
virtual void EnableLooping(bool loop) = 0;
|
||||
void EnableSpatialization(bool spatialization);
|
||||
|
||||
float GetAttenuation() const;
|
||||
virtual nzUInt32 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;
|
||||
float GetVolume() const;
|
||||
float GetAttenuation() const;
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
float GetMinDistance() const;
|
||||
float GetPitch() const;
|
||||
virtual UInt32 GetPlayingOffset() const = 0;
|
||||
Vector3f GetPosition() const;
|
||||
Vector3f GetVelocity() const;
|
||||
virtual SoundStatus GetStatus() const = 0;
|
||||
float GetVolume() const;
|
||||
|
||||
virtual bool IsLooping() const = 0;
|
||||
bool IsSpatialized() const;
|
||||
virtual bool IsLooping() const = 0;
|
||||
bool IsSpatialized() const;
|
||||
|
||||
virtual void Pause() = 0;
|
||||
virtual void Play() = 0;
|
||||
virtual void Pause() = 0;
|
||||
virtual void Play() = 0;
|
||||
|
||||
void SetAttenuation(float attenuation);
|
||||
void SetMinDistance(float minDistance);
|
||||
void SetPitch(float pitch);
|
||||
void SetPosition(const NzVector3f& position);
|
||||
void SetPosition(float x, float y, float z);
|
||||
void SetVelocity(const NzVector3f& velocity);
|
||||
void SetVelocity(float velX, float velY, float velZ);
|
||||
void SetVolume(float volume);
|
||||
void SetAttenuation(float attenuation);
|
||||
void SetMinDistance(float minDistance);
|
||||
void SetPitch(float pitch);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetPosition(float x, float y, float z);
|
||||
void SetVelocity(const Vector3f& velocity);
|
||||
void SetVelocity(float velX, float velY, float velZ);
|
||||
void SetVolume(float volume);
|
||||
|
||||
virtual void Stop() = 0;
|
||||
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
|
||||
|
||||
unsigned int m_source;
|
||||
};
|
||||
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
|
||||
{
|
||||
public:
|
||||
NzSoundStream() = default;
|
||||
virtual ~NzSoundStream();
|
||||
class NAZARA_AUDIO_API SoundStream
|
||||
{
|
||||
public:
|
||||
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 unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||
virtual void Seek(UInt32 offset) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SOUNDSTREAM_HPP
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@
|
|||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Core/MemoryStream.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>
|
||||
|
|
|
|||
|
|
@ -8,19 +8,26 @@
|
|||
#define NAZARA_ABSTRACTHASH_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_CORE_API NzAbstractHash : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzAbstractHash() = default;
|
||||
virtual ~NzAbstractHash();
|
||||
class HashDigest;
|
||||
|
||||
virtual void Append(const nzUInt8* data, unsigned int len) = 0;
|
||||
virtual void Begin() = 0;
|
||||
virtual NzHashDigest End() = 0;
|
||||
};
|
||||
class NAZARA_CORE_API AbstractHash
|
||||
{
|
||||
public:
|
||||
AbstractHash() = default;
|
||||
AbstractHash(const AbstractHash&) = delete;
|
||||
AbstractHash(AbstractHash&&) = default;
|
||||
virtual ~AbstractHash();
|
||||
|
||||
virtual void Append(const UInt8* data, unsigned int len) = 0;
|
||||
virtual void Begin() = 0;
|
||||
virtual HashDigest End() = 0;
|
||||
|
||||
AbstractHash& operator=(const AbstractHash&) = delete;
|
||||
AbstractHash& operator=(AbstractHash&&) = default;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACTHASH_HPP
|
||||
|
|
|
|||
|
|
@ -11,12 +11,15 @@
|
|||
#include <functional>
|
||||
#include <tuple>
|
||||
|
||||
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
|
||||
{
|
||||
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> void HashCombine(std::size_t& seed, const T& v);
|
||||
|
||||
template<typename T>
|
||||
struct NzTypeTag {};
|
||||
template<typename T>
|
||||
struct TypeTag {};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Algorithm.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,49 +8,55 @@
|
|||
|
||||
#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
|
||||
{
|
||||
return std::forward<F>(fn)(std::get<S>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
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;
|
||||
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))...);
|
||||
}
|
||||
}
|
||||
|
||||
return NzApplyImplFunc(std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
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;
|
||||
|
||||
template<typename O, typename F, typename Tuple, size_t... S>
|
||||
auto NzApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
{
|
||||
return (object .* std::forward<F>(fn))(std::get<S>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
return Detail::ApplyImplFunc(std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
|
||||
template<typename O, typename F, typename Tuple>
|
||||
auto NzApply(O& object, F&& fn, Tuple&& t)
|
||||
{
|
||||
constexpr std::size_t tSize = std::tuple_size<typename std::remove_reference<Tuple>::type>::value;
|
||||
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 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::ApplyImplMethod(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 HashCombine(std::size_t& seed, const T& v)
|
||||
{
|
||||
const UInt64 kMul = 0x9ddfea08eb382d69ULL;
|
||||
|
||||
std::hash<T> hasher;
|
||||
nzUInt64 a = (hasher(v) ^ seed) * kMul;
|
||||
a ^= (a >> 47);
|
||||
std::hash<T> hasher;
|
||||
UInt64 a = (hasher(v) ^ seed) * kMul;
|
||||
a ^= (a >> 47);
|
||||
|
||||
nzUInt64 b = (seed ^ a) * kMul;
|
||||
b ^= (b >> 47);
|
||||
UInt64 b = (seed ^ a) * kMul;
|
||||
b ^= (b >> 47);
|
||||
|
||||
seed = static_cast<std::size_t>(b * kMul);
|
||||
seed = static_cast<std::size_t>(b * kMul);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -12,165 +12,168 @@
|
|||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
class NzAbstractHash;
|
||||
|
||||
template<typename Block = nzUInt32, class Allocator = std::allocator<Block>>
|
||||
class NzBitset
|
||||
namespace Nz
|
||||
{
|
||||
static_assert(std::is_integral<Block>::value && std::is_unsigned<Block>::value, "Block must be a unsigned integral type");
|
||||
class AbstractHash;
|
||||
|
||||
public:
|
||||
class Bit;
|
||||
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");
|
||||
|
||||
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;
|
||||
public:
|
||||
class Bit;
|
||||
|
||||
void Clear();
|
||||
unsigned int Count() const;
|
||||
void Flip();
|
||||
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;
|
||||
|
||||
unsigned int FindFirst() const;
|
||||
unsigned int FindNext(unsigned int bit) const;
|
||||
void Clear();
|
||||
unsigned int Count() const;
|
||||
void Flip();
|
||||
|
||||
Block GetBlock(unsigned int i) const;
|
||||
unsigned int GetBlockCount() const;
|
||||
unsigned int GetCapacity() const;
|
||||
unsigned int GetSize() const;
|
||||
unsigned int FindFirst() const;
|
||||
unsigned int FindNext(unsigned int bit) 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);
|
||||
Block GetBlock(unsigned int i) const;
|
||||
unsigned int GetBlockCount() const;
|
||||
unsigned int GetCapacity() const;
|
||||
unsigned int GetSize() const;
|
||||
|
||||
bool Intersects(const NzBitset& bitset) const;
|
||||
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);
|
||||
|
||||
void Reserve(unsigned int bitCount);
|
||||
void Resize(unsigned int bitCount, bool defaultVal = false);
|
||||
bool Intersects(const Bitset& bitset) const;
|
||||
|
||||
void Reset();
|
||||
void Reset(unsigned int bit);
|
||||
void Reserve(unsigned int bitCount);
|
||||
void Resize(unsigned int bitCount, bool defaultVal = false);
|
||||
|
||||
void Set(bool val = true);
|
||||
void Set(unsigned int bit, bool val = true);
|
||||
void SetBlock(unsigned int i, Block block);
|
||||
void Reset();
|
||||
void Reset(unsigned int bit);
|
||||
|
||||
void Swap(NzBitset& bitset);
|
||||
void Set(bool val = true);
|
||||
void Set(unsigned int bit, bool val = true);
|
||||
void SetBlock(unsigned int i, Block block);
|
||||
|
||||
bool Test(unsigned int bit) const;
|
||||
bool TestAll() const;
|
||||
bool TestAny() const;
|
||||
bool TestNone() const;
|
||||
void Swap(Bitset& bitset);
|
||||
|
||||
template<typename T> T To() const;
|
||||
NzString ToString() const;
|
||||
bool Test(unsigned int bit) const;
|
||||
bool TestAll() const;
|
||||
bool TestAny() const;
|
||||
bool TestNone() const;
|
||||
|
||||
void UnboundedReset(unsigned int bit);
|
||||
void UnboundedSet(unsigned int bit, bool val = true);
|
||||
bool UnboundedTest(unsigned int bit) const;
|
||||
template<typename T> T To() const;
|
||||
String ToString() const;
|
||||
|
||||
Bit operator[](int index);
|
||||
bool operator[](int index) const;
|
||||
void UnboundedReset(unsigned int bit);
|
||||
void UnboundedSet(unsigned int bit, bool val = true);
|
||||
bool UnboundedTest(unsigned int bit) const;
|
||||
|
||||
NzBitset operator~() const;
|
||||
Bit operator[](int index);
|
||||
bool operator[](int index) const;
|
||||
|
||||
NzBitset& operator=(const NzBitset& bitset) = default;
|
||||
NzBitset& operator=(const NzString& bits);
|
||||
NzBitset& operator=(NzBitset&& bitset) noexcept = default;
|
||||
Bitset operator~() const;
|
||||
|
||||
NzBitset& operator&=(const NzBitset& bitset);
|
||||
NzBitset& operator|=(const NzBitset& bitset);
|
||||
NzBitset& operator^=(const NzBitset& bitset);
|
||||
Bitset& operator=(const Bitset& bitset) = default;
|
||||
Bitset& operator=(const String& bits);
|
||||
Bitset& operator=(Bitset&& bitset) noexcept = default;
|
||||
|
||||
static Block fullBitMask;
|
||||
static unsigned int bitsPerBlock;
|
||||
static unsigned int npos;
|
||||
Bitset& operator&=(const Bitset& bitset);
|
||||
Bitset& operator|=(const Bitset& bitset);
|
||||
Bitset& operator^=(const Bitset& bitset);
|
||||
|
||||
private:
|
||||
unsigned int FindFirstFrom(unsigned int blockIndex) const;
|
||||
Block GetLastBlockMask() const;
|
||||
void ResetExtraBits();
|
||||
static Block fullBitMask;
|
||||
static unsigned int bitsPerBlock;
|
||||
static unsigned int npos;
|
||||
|
||||
static unsigned int ComputeBlockCount(unsigned int bitCount);
|
||||
static unsigned int GetBitIndex(unsigned int bit);
|
||||
static unsigned int GetBlockIndex(unsigned int bit);
|
||||
private:
|
||||
unsigned int FindFirstFrom(unsigned int blockIndex) const;
|
||||
Block GetLastBlockMask() const;
|
||||
void ResetExtraBits();
|
||||
|
||||
std::vector<Block, Allocator> m_blocks;
|
||||
unsigned int m_bitCount;
|
||||
};
|
||||
static unsigned int ComputeBlockCount(unsigned int bitCount);
|
||||
static unsigned int GetBitIndex(unsigned int bit);
|
||||
static unsigned int GetBlockIndex(unsigned int bit);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator==(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
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>
|
||||
class Bitset<Block, Allocator>::Bit
|
||||
{
|
||||
friend Bitset<Block, Allocator>;
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
public:
|
||||
Bit(const Bit& bit) = default;
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<=(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
Bit& Flip();
|
||||
Bit& Reset();
|
||||
Bit& Set(bool val = true);
|
||||
bool Test() const;
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
template<bool BadCall = true>
|
||||
void* operator&() const;
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>=(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
operator bool() const;
|
||||
Bit& operator=(bool val);
|
||||
Bit& operator=(const Bit& bit);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
NzBitset<Block, Allocator> operator&(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
Bit& operator|=(bool val);
|
||||
Bit& operator&=(bool val);
|
||||
Bit& operator^=(bool val);
|
||||
Bit& operator-=(bool val);
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
NzBitset<Block, Allocator> operator|(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
private:
|
||||
Bit(Block& block, Block mask) :
|
||||
m_block(block),
|
||||
m_mask(mask)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
NzBitset<Block, Allocator> operator^(const NzBitset<Block, Allocator>& lhs, const NzBitset<Block, Allocator>& rhs);
|
||||
Block& m_block;
|
||||
Block m_mask;
|
||||
};
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
class NzBitset<Block, Allocator>::Bit
|
||||
{
|
||||
friend NzBitset<Block, Allocator>;
|
||||
template<typename Block, class Allocator>
|
||||
bool operator==(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
public:
|
||||
Bit(const Bit& bit) = default;
|
||||
template<typename Block, class Allocator>
|
||||
bool operator!=(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
Bit& Flip();
|
||||
Bit& Reset();
|
||||
Bit& Set(bool val = true);
|
||||
bool Test() const;
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
template<bool BadCall = true>
|
||||
void* operator&() const;
|
||||
template<typename Block, class Allocator>
|
||||
bool operator<=(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
operator bool() const;
|
||||
Bit& operator=(bool val);
|
||||
Bit& operator=(const Bit& bit);
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
Bit& operator|=(bool val);
|
||||
Bit& operator&=(bool val);
|
||||
Bit& operator^=(bool val);
|
||||
Bit& operator-=(bool val);
|
||||
template<typename Block, class Allocator>
|
||||
bool operator>=(const Bitset<Block, Allocator>& lhs, const Nz::Bitset<Block, Allocator>& rhs);
|
||||
|
||||
private:
|
||||
Bit(Block& block, Block mask) :
|
||||
m_block(block),
|
||||
m_mask(mask)
|
||||
{
|
||||
}
|
||||
template<typename Block, class Allocator>
|
||||
Bitset<Block, Allocator> operator&(const Bitset<Block, Allocator>& lhs, const Bitset<Block, Allocator>& rhs);
|
||||
|
||||
Block& m_block;
|
||||
Block m_mask;
|
||||
};
|
||||
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
|
|
@ -13,125 +13,128 @@
|
|||
#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;
|
||||
|
||||
public:
|
||||
// types:
|
||||
using allocator_type = Container::allocator_type;
|
||||
using const_iterator = Container::const_iterator;
|
||||
using const_reference = Container::const_reference;
|
||||
using const_pointer = Container::const_pointer;
|
||||
using const_reverse_iterator = Container::const_reverse_iterator;
|
||||
using difference_type = Container::difference_type;
|
||||
using pointer = Container::pointer;
|
||||
using iterator = Container::iterator;
|
||||
using reference = Container::reference;
|
||||
using reverse_iterator = Container::reverse_iterator;
|
||||
using size_type = Container::size_type;
|
||||
using value_type = Container::value_type;
|
||||
class NAZARA_CORE_API ByteArray : public Hashable
|
||||
{
|
||||
using Container = std::vector<UInt8>;
|
||||
|
||||
// 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;
|
||||
public:
|
||||
// types:
|
||||
using allocator_type = Container::allocator_type;
|
||||
using const_iterator = Container::const_iterator;
|
||||
using const_reference = Container::const_reference;
|
||||
using const_pointer = Container::const_pointer;
|
||||
using const_reverse_iterator = Container::const_reverse_iterator;
|
||||
using difference_type = Container::difference_type;
|
||||
using pointer = Container::pointer;
|
||||
using iterator = Container::iterator;
|
||||
using reference = Container::reference;
|
||||
using reverse_iterator = Container::reverse_iterator;
|
||||
using size_type = Container::size_type;
|
||||
using value_type = Container::value_type;
|
||||
|
||||
inline iterator Append(const void* buffer, size_type size);
|
||||
inline iterator Append(const NzByteArray& other);
|
||||
template <class InputIterator> void Assign(InputIterator first, InputIterator last);
|
||||
inline void Assign(size_type n, value_type value);
|
||||
// construct/destroy:
|
||||
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 reference Back();
|
||||
inline const_reference Back() const;
|
||||
inline iterator Append(const void* buffer, size_type size);
|
||||
inline iterator Append(const ByteArray& other);
|
||||
template <class InputIterator> void Assign(InputIterator first, InputIterator last);
|
||||
inline void Assign(size_type n, value_type value);
|
||||
|
||||
inline void Clear(bool keepBuffer = false);
|
||||
inline reference Back();
|
||||
inline const_reference Back() const;
|
||||
|
||||
inline iterator Erase(const_iterator pos);
|
||||
inline iterator Erase(const_iterator first, const_iterator last);
|
||||
inline void Clear(bool keepBuffer = false);
|
||||
|
||||
inline reference Front();
|
||||
inline const_reference Front() const;
|
||||
inline iterator Erase(const_iterator pos);
|
||||
inline iterator Erase(const_iterator first, const_iterator last);
|
||||
|
||||
inline allocator_type GetAllocator() const;
|
||||
inline pointer GetBuffer();
|
||||
inline size_type GetCapacity() const noexcept;
|
||||
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 reference Front();
|
||||
inline const_reference Front() 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, size_type n, value_type byte);
|
||||
template <class InputIterator> iterator Insert(const_iterator pos, InputIterator first, InputIterator last);
|
||||
inline bool IsEmpty() const noexcept;
|
||||
inline allocator_type GetAllocator() const;
|
||||
inline pointer GetBuffer();
|
||||
inline size_type GetCapacity() const noexcept;
|
||||
inline const_pointer GetConstBuffer() const;
|
||||
inline size_type GetMaxSize() const noexcept;
|
||||
inline size_type GetSize() const noexcept;
|
||||
inline ByteArray GetSubArray(const_iterator startPos, const_iterator endPos) const;
|
||||
|
||||
inline void PopBack();
|
||||
inline void PopFront();
|
||||
inline iterator Prepend(const void* buffer, size_type size);
|
||||
inline iterator Prepend(const NzByteArray& other);
|
||||
inline void PushBack(value_type byte);
|
||||
inline void PushFront(value_type byte);
|
||||
inline iterator Insert(const_iterator pos, const void* buffer, size_type n);
|
||||
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;
|
||||
|
||||
inline void Reserve(size_type bufferSize);
|
||||
inline void Resize(size_type newSize);
|
||||
inline void Resize(size_type newSize, value_type byte);
|
||||
inline void PopBack();
|
||||
inline void PopFront();
|
||||
inline iterator Prepend(const void* buffer, size_type size);
|
||||
inline iterator Prepend(const ByteArray& other);
|
||||
inline void PushBack(value_type byte);
|
||||
inline void PushFront(value_type byte);
|
||||
|
||||
inline void ShrinkToFit();
|
||||
inline void Swap(NzByteArray& other);
|
||||
inline void Reserve(size_type bufferSize);
|
||||
inline void Resize(size_type newSize);
|
||||
inline void Resize(size_type newSize, value_type byte);
|
||||
|
||||
inline NzString ToString() const;
|
||||
inline void ShrinkToFit();
|
||||
inline void Swap(ByteArray& other);
|
||||
|
||||
// STL interface
|
||||
inline iterator begin() noexcept;
|
||||
inline const_iterator begin() const noexcept;
|
||||
inline bool empty() const noexcept;
|
||||
inline iterator end() noexcept;
|
||||
inline const_iterator end() const noexcept;
|
||||
inline reverse_iterator rbegin() noexcept;
|
||||
inline const_reverse_iterator rbegin() const noexcept;
|
||||
inline reverse_iterator rend() noexcept;
|
||||
inline const_reverse_iterator rend() const noexcept;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
inline const_iterator cend() const noexcept;
|
||||
inline const_reverse_iterator crbegin() const noexcept;
|
||||
inline const_reverse_iterator crend() const noexcept;
|
||||
inline size_type size() const noexcept;
|
||||
inline String ToString() const;
|
||||
|
||||
// Operators
|
||||
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);
|
||||
// STL interface
|
||||
inline iterator begin() noexcept;
|
||||
inline const_iterator begin() const noexcept;
|
||||
inline bool empty() const noexcept;
|
||||
inline iterator end() noexcept;
|
||||
inline const_iterator end() const noexcept;
|
||||
inline reverse_iterator rbegin() noexcept;
|
||||
inline const_reverse_iterator rbegin() const noexcept;
|
||||
inline reverse_iterator rend() noexcept;
|
||||
inline const_reverse_iterator rend() const noexcept;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
inline const_iterator cend() const noexcept;
|
||||
inline const_reverse_iterator crbegin() const noexcept;
|
||||
inline const_reverse_iterator crend() const noexcept;
|
||||
inline size_type size() const noexcept;
|
||||
|
||||
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;
|
||||
// Operators
|
||||
inline reference operator[](size_type pos);
|
||||
inline const_reference operator[](size_type pos) const;
|
||||
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);
|
||||
|
||||
private:
|
||||
bool FillHash(NzAbstractHash* hash) 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;
|
||||
|
||||
Container m_array;
|
||||
};
|
||||
private:
|
||||
bool FillHash(AbstractHash* hash) const;
|
||||
|
||||
NAZARA_CORE_API std::ostream& operator<<(std::ostream& out, const NzByteArray& byteArray);
|
||||
Container m_array;
|
||||
};
|
||||
}
|
||||
|
||||
NAZARA_CORE_API std::ostream& operator<<(std::ostream& out, const Nz::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,330 @@
|
|||
// 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()
|
||||
namespace Nz
|
||||
{
|
||||
m_array.reserve(n);
|
||||
}
|
||||
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)
|
||||
{
|
||||
return Insert(end(), static_cast<const_pointer>(buffer), static_cast<const_pointer>(buffer) + 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)
|
||||
{
|
||||
return Insert(end(), other.begin(), other.end());
|
||||
}
|
||||
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)
|
||||
{
|
||||
m_array.assign(n, 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)
|
||||
{
|
||||
m_array.assign(first, last);
|
||||
}
|
||||
template <class InputIterator>
|
||||
void ByteArray::Assign(InputIterator first, InputIterator last)
|
||||
{
|
||||
m_array.assign(first, last);
|
||||
}
|
||||
|
||||
inline NzByteArray::reference NzByteArray::Back()
|
||||
{
|
||||
return m_array.back();
|
||||
}
|
||||
inline ByteArray::reference ByteArray::Back()
|
||||
{
|
||||
return m_array.back();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reference NzByteArray::Back() const
|
||||
{
|
||||
return m_array.back();
|
||||
}
|
||||
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 ByteArray::iterator ByteArray::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 ByteArray::iterator ByteArray::Erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return m_array.erase(first, last);
|
||||
}
|
||||
|
||||
inline NzByteArray::reference NzByteArray::Front()
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
inline ByteArray::reference ByteArray::Front()
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reference NzByteArray::Front() const
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
inline ByteArray::const_reference ByteArray::Front() const
|
||||
{
|
||||
return m_array.front();
|
||||
}
|
||||
|
||||
inline NzByteArray::allocator_type NzByteArray::GetAllocator() const
|
||||
{
|
||||
return m_array.get_allocator();
|
||||
}
|
||||
inline ByteArray::allocator_type ByteArray::GetAllocator() const
|
||||
{
|
||||
return m_array.get_allocator();
|
||||
}
|
||||
|
||||
inline NzByteArray::pointer NzByteArray::GetBuffer()
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
inline ByteArray::pointer ByteArray::GetBuffer()
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::GetCapacity() const noexcept
|
||||
{
|
||||
return m_array.capacity();
|
||||
}
|
||||
inline ByteArray::size_type ByteArray::GetCapacity() const noexcept
|
||||
{
|
||||
return m_array.capacity();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_pointer NzByteArray::GetConstBuffer() const
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
inline ByteArray::const_pointer ByteArray::GetConstBuffer() const
|
||||
{
|
||||
return m_array.data();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::GetMaxSize() const noexcept
|
||||
{
|
||||
return m_array.max_size();
|
||||
}
|
||||
inline ByteArray::size_type ByteArray::GetMaxSize() const noexcept
|
||||
{
|
||||
return m_array.max_size();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::GetSize() const noexcept
|
||||
{
|
||||
return m_array.size();
|
||||
}
|
||||
inline ByteArray::size_type ByteArray::GetSize() const noexcept
|
||||
{
|
||||
return m_array.size();
|
||||
}
|
||||
|
||||
inline NzByteArray NzByteArray::GetSubArray(const_iterator startPos, const_iterator endPos) const
|
||||
{
|
||||
return NzByteArray(startPos, endPos);
|
||||
}
|
||||
inline ByteArray ByteArray::GetSubArray(const_iterator startPos, const_iterator endPos) const
|
||||
{
|
||||
return ByteArray(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 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 NzByteArray::iterator NzByteArray::Insert(const_iterator pos, const NzByteArray& other)
|
||||
{
|
||||
return m_array.insert(pos, other.begin(), other.end());
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, const ByteArray& 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);
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::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);
|
||||
}
|
||||
template <class InputIterator>
|
||||
ByteArray::iterator ByteArray::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 bool ByteArray::IsEmpty() const noexcept
|
||||
{
|
||||
return m_array.empty();
|
||||
}
|
||||
|
||||
inline void NzByteArray::PopBack()
|
||||
{
|
||||
Erase(end() - 1);
|
||||
}
|
||||
inline void ByteArray::PopBack()
|
||||
{
|
||||
Erase(end() - 1);
|
||||
}
|
||||
|
||||
inline void NzByteArray::PopFront()
|
||||
{
|
||||
Erase(begin());
|
||||
}
|
||||
inline void ByteArray::PopFront()
|
||||
{
|
||||
Erase(begin());
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::Prepend(const void* buffer, size_type n)
|
||||
{
|
||||
return Insert(begin(), buffer, n);
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::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 ByteArray::iterator ByteArray::Prepend(const ByteArray& other)
|
||||
{
|
||||
return Insert(begin(), other);
|
||||
}
|
||||
|
||||
inline void NzByteArray::PushBack(const value_type byte)
|
||||
{
|
||||
m_array.push_back(byte);
|
||||
}
|
||||
inline void ByteArray::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 ByteArray::PushFront(const value_type byte)
|
||||
{
|
||||
m_array.insert(begin(), 1, byte);
|
||||
}
|
||||
|
||||
inline void NzByteArray::Reserve(size_type bufferSize)
|
||||
{
|
||||
m_array.reserve(bufferSize);
|
||||
}
|
||||
inline void ByteArray::Reserve(size_type bufferSize)
|
||||
{
|
||||
m_array.reserve(bufferSize);
|
||||
}
|
||||
|
||||
inline void NzByteArray::Resize(size_type newSize)
|
||||
{
|
||||
m_array.resize(newSize);
|
||||
}
|
||||
inline void ByteArray::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 ByteArray::Resize(size_type newSize, const value_type byte)
|
||||
{
|
||||
m_array.resize(newSize, byte);
|
||||
}
|
||||
|
||||
inline void NzByteArray::ShrinkToFit()
|
||||
{
|
||||
m_array.shrink_to_fit();
|
||||
}
|
||||
inline void ByteArray::ShrinkToFit()
|
||||
{
|
||||
m_array.shrink_to_fit();
|
||||
}
|
||||
|
||||
inline void NzByteArray::Swap(NzByteArray& other)
|
||||
{
|
||||
m_array.swap(other.m_array);
|
||||
}
|
||||
inline void ByteArray::Swap(ByteArray& other)
|
||||
{
|
||||
m_array.swap(other.m_array);
|
||||
}
|
||||
|
||||
inline NzString NzByteArray::ToString() const
|
||||
{
|
||||
return NzString(reinterpret_cast<const char*>(GetConstBuffer()), GetSize());
|
||||
}
|
||||
inline String ByteArray::ToString() const
|
||||
{
|
||||
return String(reinterpret_cast<const char*>(GetConstBuffer()), GetSize());
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::begin() noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::begin() noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::begin() const noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
inline ByteArray::const_iterator ByteArray::begin() const noexcept
|
||||
{
|
||||
return m_array.begin();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::cbegin() const noexcept
|
||||
{
|
||||
return m_array.cbegin();
|
||||
}
|
||||
inline ByteArray::const_iterator ByteArray::cbegin() const noexcept
|
||||
{
|
||||
return m_array.cbegin();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::cend() const noexcept
|
||||
{
|
||||
return m_array.cend();
|
||||
}
|
||||
inline ByteArray::const_iterator ByteArray::cend() const noexcept
|
||||
{
|
||||
return m_array.cend();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reverse_iterator NzByteArray::crbegin() const noexcept
|
||||
{
|
||||
return m_array.crbegin();
|
||||
}
|
||||
inline ByteArray::const_reverse_iterator ByteArray::crbegin() const noexcept
|
||||
{
|
||||
return m_array.crbegin();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reverse_iterator NzByteArray::crend() const noexcept
|
||||
{
|
||||
return m_array.crend();
|
||||
}
|
||||
inline ByteArray::const_reverse_iterator ByteArray::crend() const noexcept
|
||||
{
|
||||
return m_array.crend();
|
||||
}
|
||||
|
||||
inline bool NzByteArray::empty() const noexcept
|
||||
{
|
||||
return m_array.empty();
|
||||
}
|
||||
inline bool ByteArray::empty() const noexcept
|
||||
{
|
||||
return m_array.empty();
|
||||
}
|
||||
|
||||
inline NzByteArray::iterator NzByteArray::end() noexcept
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
inline ByteArray::iterator ByteArray::end() noexcept
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_iterator NzByteArray::end() const noexcept
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
inline ByteArray::const_iterator ByteArray::end() const noexcept
|
||||
{
|
||||
return m_array.end();
|
||||
}
|
||||
|
||||
inline NzByteArray::reverse_iterator NzByteArray::rbegin() noexcept
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
inline ByteArray::reverse_iterator ByteArray::rbegin() noexcept
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reverse_iterator NzByteArray::rbegin() const noexcept
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
inline ByteArray::const_reverse_iterator ByteArray::rbegin() const noexcept
|
||||
{
|
||||
return m_array.rbegin();
|
||||
}
|
||||
|
||||
inline NzByteArray::reverse_iterator NzByteArray::rend() noexcept
|
||||
{
|
||||
return m_array.rend();
|
||||
}
|
||||
inline ByteArray::reverse_iterator ByteArray::rend() noexcept
|
||||
{
|
||||
return m_array.rend();
|
||||
}
|
||||
|
||||
inline NzByteArray::size_type NzByteArray::size() const noexcept
|
||||
{
|
||||
return GetSize();
|
||||
}
|
||||
inline ByteArray::size_type ByteArray::size() const noexcept
|
||||
{
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
inline NzByteArray::reference NzByteArray::operator[](size_type pos)
|
||||
{
|
||||
NazaraAssert(pos < GetSize(), "Index out of range");
|
||||
inline ByteArray::reference ByteArray::operator[](size_type pos)
|
||||
{
|
||||
NazaraAssert(pos < GetSize(), "Index out of range");
|
||||
|
||||
return m_array[pos];
|
||||
}
|
||||
return m_array[pos];
|
||||
}
|
||||
|
||||
inline NzByteArray::const_reference NzByteArray::operator[](size_type pos) const
|
||||
{
|
||||
NazaraAssert(pos < GetSize(), "Index out of range");
|
||||
inline ByteArray::const_reference ByteArray::operator[](size_type pos) const
|
||||
{
|
||||
NazaraAssert(pos < GetSize(), "Index out of range");
|
||||
|
||||
return m_array[pos];
|
||||
}
|
||||
return m_array[pos];
|
||||
}
|
||||
|
||||
inline NzByteArray NzByteArray::operator+(const NzByteArray& other) const
|
||||
{
|
||||
NzByteArray tmp(*this);
|
||||
tmp += other;
|
||||
inline ByteArray ByteArray::operator+(const ByteArray& other) const
|
||||
{
|
||||
ByteArray tmp(*this);
|
||||
tmp += other;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline NzByteArray& NzByteArray::operator+=(const NzByteArray& other)
|
||||
{
|
||||
Append(other);
|
||||
inline ByteArray& ByteArray::operator+=(const ByteArray& other)
|
||||
{
|
||||
Append(other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator==(const NzByteArray& rhs) const
|
||||
{
|
||||
return m_array == rhs.m_array;
|
||||
}
|
||||
inline bool ByteArray::operator==(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array == rhs.m_array;
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator!=(const NzByteArray& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
inline bool ByteArray::operator!=(const ByteArray& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator<(const NzByteArray& rhs) const
|
||||
{
|
||||
return m_array < rhs.m_array;
|
||||
}
|
||||
inline bool ByteArray::operator<(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array < rhs.m_array;
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator<=(const NzByteArray& rhs) const
|
||||
{
|
||||
return m_array <= rhs.m_array;
|
||||
}
|
||||
inline bool ByteArray::operator<=(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array <= rhs.m_array;
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator>(const NzByteArray& rhs) const
|
||||
{
|
||||
return m_array > rhs.m_array;
|
||||
}
|
||||
inline bool ByteArray::operator>(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array > rhs.m_array;
|
||||
}
|
||||
|
||||
inline bool NzByteArray::operator>=(const NzByteArray& rhs) const
|
||||
{
|
||||
return m_array >= rhs.m_array;
|
||||
inline bool ByteArray::operator>=(const ByteArray& rhs) const
|
||||
{
|
||||
return m_array >= rhs.m_array;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
using Func = std::function<void()>;
|
||||
class CallOnExit
|
||||
{
|
||||
using Func = std::function<void()>;
|
||||
|
||||
public:
|
||||
NzCallOnExit(Func func = nullptr);
|
||||
~NzCallOnExit();
|
||||
public:
|
||||
CallOnExit(Func func = nullptr);
|
||||
CallOnExit(const CallOnExit&) = delete;
|
||||
CallOnExit(CallOnExit&&) = delete;
|
||||
~CallOnExit();
|
||||
|
||||
void CallAndReset(Func func = nullptr);
|
||||
void Reset(Func func = nullptr);
|
||||
void CallAndReset(Func func = nullptr);
|
||||
void Reset(Func func = nullptr);
|
||||
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
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()
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
}
|
||||
inline CallOnExit::~CallOnExit()
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::CallAndReset(Func func)
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
inline void CallOnExit::CallAndReset(Func func)
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
|
||||
Reset(func);
|
||||
}
|
||||
Reset(func);
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::Reset(Func func)
|
||||
{
|
||||
m_func = func;
|
||||
inline void CallOnExit::Reset(Func func)
|
||||
{
|
||||
m_func = func;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -15,35 +15,41 @@
|
|||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NAZARA_CORE_API NzClock
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzClock(nzUInt64 startingValue = 0, bool paused = false);
|
||||
NzClock(const NzClock& clock) = default;
|
||||
class NAZARA_CORE_API Clock
|
||||
{
|
||||
public:
|
||||
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;
|
||||
float GetSeconds() const;
|
||||
UInt64 GetMicroseconds() const;
|
||||
UInt64 GetMilliseconds() const;
|
||||
|
||||
bool IsPaused() const;
|
||||
bool IsPaused() const;
|
||||
|
||||
void Pause();
|
||||
void Restart();
|
||||
void Unpause();
|
||||
void Pause();
|
||||
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)
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
nzUInt64 m_elapsedTime;
|
||||
nzUInt64 m_refTime;
|
||||
bool m_paused;
|
||||
};
|
||||
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
|
||||
{
|
||||
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;
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
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);
|
||||
};
|
||||
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,411 +9,414 @@
|
|||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline NzColor::NzColor()
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
inline NzColor::NzColor(nzUInt8 red, nzUInt8 green, nzUInt8 blue, nzUInt8 alpha) :
|
||||
r(red),
|
||||
g(green),
|
||||
b(blue),
|
||||
a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzColor::NzColor(nzUInt8 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 NzString NzColor::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Color(" << static_cast<int>(r) << ", " << static_cast<int>(g) << ", " << static_cast<int>(b);
|
||||
|
||||
if (a != 255)
|
||||
ss << ", " << static_cast<int>(a);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
inline NzColor NzColor::operator+=(const NzColor& color)
|
||||
{
|
||||
return operator=(operator+(color));
|
||||
}
|
||||
|
||||
inline NzColor NzColor::operator*=(const NzColor& color)
|
||||
{
|
||||
return operator=(operator*(color));
|
||||
}
|
||||
|
||||
inline bool NzColor::operator==(const NzColor& color) const
|
||||
{
|
||||
return r == color.r && g == color.g && b == color.b && a == color.a;
|
||||
}
|
||||
|
||||
inline bool NzColor::operator!=(const NzColor& color) const
|
||||
{
|
||||
return !operator==(color);
|
||||
}
|
||||
|
||||
// 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 NzColor NzColor::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)
|
||||
{
|
||||
if (saturation == 0)
|
||||
inline Color::Color()
|
||||
{
|
||||
// RGB results from 0 to 255
|
||||
return NzColor(lightness * 255,
|
||||
lightness * 255,
|
||||
lightness * 255);
|
||||
}
|
||||
else
|
||||
|
||||
inline Color::Color(UInt8 red, UInt8 green, UInt8 blue, UInt8 alpha) :
|
||||
r(red),
|
||||
g(green),
|
||||
b(blue),
|
||||
a(alpha)
|
||||
{
|
||||
// Norme Windows
|
||||
float l = lightness/240.f;
|
||||
float h = hue/240.f;
|
||||
float s = saturation/240.f;
|
||||
|
||||
float v2;
|
||||
if (l < 0.5f)
|
||||
v2 = l * (1.f + s);
|
||||
else
|
||||
v2 = (l + s) - (s*l);
|
||||
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
||||
inline NzColor NzColor::FromHSV(float hue, float saturation, float value)
|
||||
{
|
||||
if (NzNumberEquals(saturation, 0.f))
|
||||
return NzColor(static_cast<nzUInt8>(value * 255.f));
|
||||
else
|
||||
inline Color::Color(UInt8 lightness) :
|
||||
r(lightness),
|
||||
g(lightness),
|
||||
b(lightness),
|
||||
a(255)
|
||||
{
|
||||
float h = hue/360.f * 6.f;
|
||||
float s = saturation/360.f;
|
||||
}
|
||||
|
||||
if (NzNumberEquals(h, 6.f))
|
||||
h = 0; // hue must be < 1
|
||||
inline Color::Color(UInt8 vec[3], UInt8 alpha) :
|
||||
r(vec[0]),
|
||||
g(vec[1]),
|
||||
b(vec[2]),
|
||||
a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
int i = static_cast<unsigned int>(h);
|
||||
float v1 = value * (1.f - s);
|
||||
float v2 = value * (1.f - s * (h - i));
|
||||
float v3 = value * (1.f - s * (1.f - (h - i)));
|
||||
inline String Color::ToString() const
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Color(" << static_cast<int>(r) << ", " << static_cast<int>(g) << ", " << static_cast<int>(b);
|
||||
|
||||
float r, g, b;
|
||||
switch (i)
|
||||
if (a != 255)
|
||||
ss << ", " << static_cast<int>(a);
|
||||
|
||||
ss << ')';
|
||||
|
||||
return ss;
|
||||
}
|
||||
|
||||
inline Color Color::operator+(const Color& color) const
|
||||
{
|
||||
Color 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);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
inline Color Color::operator*(const Color& color) const
|
||||
{
|
||||
Color 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;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
inline Color Color::operator+=(const Color& color)
|
||||
{
|
||||
return operator=(operator+(color));
|
||||
}
|
||||
|
||||
inline Color Color::operator*=(const Color& color)
|
||||
{
|
||||
return operator=(operator*(color));
|
||||
}
|
||||
|
||||
inline bool Color::operator==(const Color& color) const
|
||||
{
|
||||
return r == color.r && g == color.g && b == color.b && a == color.a;
|
||||
}
|
||||
|
||||
inline bool Color::operator!=(const Color& color) const
|
||||
{
|
||||
return !operator==(color);
|
||||
}
|
||||
|
||||
// Algorithmes venant de http://www.easyrgb.com/index.php?X=MATH
|
||||
|
||||
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 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 Color Color::FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness)
|
||||
{
|
||||
if (saturation == 0)
|
||||
{
|
||||
case 0:
|
||||
r = value;
|
||||
g = v3;
|
||||
b = v1;
|
||||
break;
|
||||
// RGB results from 0 to 255
|
||||
return Color(lightness * 255,
|
||||
lightness * 255,
|
||||
lightness * 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Norme Windows
|
||||
float l = lightness/240.f;
|
||||
float h = hue/240.f;
|
||||
float s = saturation/240.f;
|
||||
|
||||
case 1:
|
||||
r = v2;
|
||||
g = value;
|
||||
b = v1;
|
||||
break;
|
||||
float v2;
|
||||
if (l < 0.5f)
|
||||
v2 = l * (1.f + s);
|
||||
else
|
||||
v2 = (l + s) - (s*l);
|
||||
|
||||
case 2:
|
||||
r = v1;
|
||||
g = value;
|
||||
b = v3;
|
||||
break;
|
||||
float v1 = 2.f * l - v2;
|
||||
|
||||
case 3:
|
||||
r = v1;
|
||||
g = v2;
|
||||
b = value;
|
||||
break;
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
||||
case 4:
|
||||
r = v3;
|
||||
g = v1;
|
||||
b = value;
|
||||
break;
|
||||
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;
|
||||
|
||||
default:
|
||||
r = value;
|
||||
g = v1;
|
||||
b = v2;
|
||||
break;
|
||||
if (NumberEquals(h, 6.f))
|
||||
h = 0; // hue must be < 1
|
||||
|
||||
int i = static_cast<unsigned int>(h);
|
||||
float v1 = value * (1.f - s);
|
||||
float v2 = value * (1.f - s * (h - i));
|
||||
float v3 = value * (1.f - s * (1.f - (h - i)));
|
||||
|
||||
float r, g, b;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
r = value;
|
||||
g = v3;
|
||||
b = v1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = v2;
|
||||
g = value;
|
||||
b = v1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = v1;
|
||||
g = value;
|
||||
b = v3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
r = v1;
|
||||
g = v2;
|
||||
b = value;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r = v3;
|
||||
g = v1;
|
||||
b = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
r = value;
|
||||
g = v1;
|
||||
b = v2;
|
||||
break;
|
||||
}
|
||||
|
||||
// RGB results from 0 to 255
|
||||
return Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
|
||||
}
|
||||
}
|
||||
inline Color Color::FromXYZ(const Vector3f& vec)
|
||||
{
|
||||
return FromXYZ(vec.x, vec.y, vec.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
|
||||
|
||||
float r = x * 3.2406f + y * -1.5372f + z * -0.4986f;
|
||||
float g = x * -0.9689f + y * 1.8758f + z * 0.0415f;
|
||||
float b = x * 0.0557f + y * -0.2040f + z * 1.0570f;
|
||||
|
||||
if (r > 0.0031308f)
|
||||
r = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
r *= 12.92f;
|
||||
|
||||
if (g > 0.0031308f)
|
||||
g = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
g *= 12.92f;
|
||||
|
||||
if (b > 0.0031308f)
|
||||
b = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
b *= 12.92f;
|
||||
|
||||
return Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
}
|
||||
|
||||
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 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 (NumberEquals(k, 1.f))
|
||||
{
|
||||
//Black
|
||||
*cyan = 0.f;
|
||||
*magenta = 0.f;
|
||||
*yellow = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*cyan = (c-k)/(1.f-k);
|
||||
*magenta = (m-k)/(1.f-k);
|
||||
*yellow = (y-k)/(1.f-k);
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
inline NzColor NzColor::FromXYZ(const NzVector3f& vec)
|
||||
{
|
||||
return FromXYZ(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
inline NzColor NzColor::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
|
||||
|
||||
float r = x * 3.2406f + y * -1.5372f + z * -0.4986f;
|
||||
float g = x * -0.9689f + y * 1.8758f + z * 0.0415f;
|
||||
float b = x * 0.0557f + y * -0.2040f + z * 1.0570f;
|
||||
|
||||
if (r > 0.0031308f)
|
||||
r = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
r *= 12.92f;
|
||||
|
||||
if (g > 0.0031308f)
|
||||
g = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
g *= 12.92f;
|
||||
|
||||
if (b > 0.0031308f)
|
||||
b = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
b *= 12.92f;
|
||||
|
||||
return NzColor(static_cast<nzUInt8>(r * 255.f), static_cast<nzUInt8>(g * 255.f), static_cast<nzUInt8>(b * 255.f));
|
||||
}
|
||||
|
||||
inline void NzColor::ToCMY(const NzColor& 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)
|
||||
{
|
||||
float c, m, y;
|
||||
ToCMY(color, &c, &m, &y);
|
||||
|
||||
float k = std::min({1.f, c, m, y});
|
||||
|
||||
if (NzNumberEquals(k, 1.f))
|
||||
{
|
||||
//Black
|
||||
*cyan = 0.f;
|
||||
*magenta = 0.f;
|
||||
*yellow = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*cyan = (c-k)/(1.f-k);
|
||||
*magenta = (m-k)/(1.f-k);
|
||||
*yellow = (y-k)/(1.f-k);
|
||||
*black = k;
|
||||
}
|
||||
|
||||
*black = k;
|
||||
}
|
||||
|
||||
inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturation, nzUInt8* lightness)
|
||||
{
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
||||
float min = std::min({r, g, b}); // Min. value of RGB
|
||||
float max = std::max({r, g, b}); // Max. value of RGB
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
float l = (max + min)/2.f;
|
||||
|
||||
if (NzNumberEquals(deltaMax, 0.f))
|
||||
inline void Color::ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness)
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSL results from 0 to 1
|
||||
*saturation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Chromatic data...
|
||||
if (l < 0.5f)
|
||||
*saturation = static_cast<nzUInt8>(deltaMax/(max+min)*240.f);
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
||||
float min = std::min({r, g, b}); // Min. value of RGB
|
||||
float max = std::max({r, g, b}); // Max. value of RGB
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
float l = (max + min)/2.f;
|
||||
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSL results from 0 to 1
|
||||
*saturation = 0;
|
||||
}
|
||||
else
|
||||
*saturation = static_cast<nzUInt8>(deltaMax/(2.f-max-min)*240.f);
|
||||
{
|
||||
//Chromatic data...
|
||||
if (l < 0.5f)
|
||||
*saturation = static_cast<UInt8>(deltaMax/(max+min)*240.f);
|
||||
else
|
||||
*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 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))
|
||||
h = deltaB - deltaG;
|
||||
else if (NzNumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
float h;
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
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)
|
||||
{
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
||||
float min = std::min({r, g, b}); //Min. value of RGB
|
||||
float max = std::max({r, g, b}); //Max. value of RGB
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
*value = max;
|
||||
|
||||
if (NzNumberEquals(deltaMax, 0.f))
|
||||
inline void Color::ToHSV(const Color& color, float* hue, float* saturation, float* value)
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSV results from 0 to 1
|
||||
*saturation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Chromatic data...
|
||||
*saturation = deltaMax/max*360.f;
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.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 min = std::min({r, g, b}); //Min. value of RGB
|
||||
float max = std::max({r, g, b}); //Max. value of RGB
|
||||
|
||||
float h;
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
if (NzNumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NzNumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
*value = max;
|
||||
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSV results from 0 to 1
|
||||
*saturation = 0;
|
||||
}
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
{
|
||||
//Chromatic data...
|
||||
*saturation = deltaMax/max*360.f;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.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;
|
||||
|
||||
*hue = h*360.f;
|
||||
float h;
|
||||
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
|
||||
*hue = h*360.f;
|
||||
}
|
||||
}
|
||||
|
||||
inline void Color::ToXYZ(const Color& color, Vector3f* vec)
|
||||
{
|
||||
return ToXYZ(color, &vec->x, &vec->y, &vec->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
|
||||
|
||||
if (r > 0.04045f)
|
||||
r = std::pow((r + 0.055f)/1.055f, 2.4f);
|
||||
else
|
||||
r /= 12.92f;
|
||||
|
||||
if (g > 0.04045f)
|
||||
g = std::pow((g + 0.055f)/1.055f, 2.4f);
|
||||
else
|
||||
g /= 12.92f;
|
||||
|
||||
if (b > 0.04045f)
|
||||
b = std::pow((b + 0.055f)/1.055f, 2.4f);
|
||||
else
|
||||
b /= 12.92f;
|
||||
|
||||
r *= 100.f;
|
||||
g *= 100.f;
|
||||
b *= 100.f;
|
||||
|
||||
//Observer. = 2°, Illuminant = D65
|
||||
*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 Color::Hue2RGB(float v1, float v2, float vH)
|
||||
{
|
||||
if (vH < 0.f)
|
||||
vH += 1;
|
||||
|
||||
if (vH > 1.f)
|
||||
vH -= 1;
|
||||
|
||||
if ((6.f * vH) < 1.f)
|
||||
return v1 + (v2-v1)*6*vH;
|
||||
|
||||
if ((2.f * vH) < 1.f)
|
||||
return v2;
|
||||
|
||||
if ((3.f * vH) < 2.f)
|
||||
return v1 + (v2 - v1)*(2.f/3.f - vH)*6;
|
||||
|
||||
return v1;
|
||||
}
|
||||
}
|
||||
|
||||
inline void NzColor::ToXYZ(const NzColor& color, NzVector3f* vec)
|
||||
{
|
||||
return ToXYZ(color, &vec->x, &vec->y, &vec->z);
|
||||
}
|
||||
|
||||
inline void NzColor::ToXYZ(const NzColor& 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
|
||||
|
||||
if (r > 0.04045f)
|
||||
r = std::pow((r + 0.055f)/1.055f, 2.4f);
|
||||
else
|
||||
r /= 12.92f;
|
||||
|
||||
if (g > 0.04045f)
|
||||
g = std::pow((g + 0.055f)/1.055f, 2.4f);
|
||||
else
|
||||
g /= 12.92f;
|
||||
|
||||
if (b > 0.04045f)
|
||||
b = std::pow((b + 0.055f)/1.055f, 2.4f);
|
||||
else
|
||||
b /= 12.92f;
|
||||
|
||||
r *= 100.f;
|
||||
g *= 100.f;
|
||||
b *= 100.f;
|
||||
|
||||
//Observer. = 2°, Illuminant = D65
|
||||
*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)
|
||||
{
|
||||
if (vH < 0.f)
|
||||
vH += 1;
|
||||
|
||||
if (vH > 1.f)
|
||||
vH -= 1;
|
||||
|
||||
if ((6.f * vH) < 1.f)
|
||||
return v1 + (v2-v1)*6*vH;
|
||||
|
||||
if ((2.f * vH) < 1.f)
|
||||
return v2;
|
||||
|
||||
if ((3.f * vH) < 2.f)
|
||||
return v1 + (v2 - v1)*(2.f/3.f - vH)*6;
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
NzConditionVariable();
|
||||
~NzConditionVariable();
|
||||
class ConditionVariableImpl;
|
||||
class Mutex;
|
||||
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
class NAZARA_CORE_API ConditionVariable
|
||||
{
|
||||
public:
|
||||
ConditionVariable();
|
||||
ConditionVariable(const ConditionVariable&) = delete;
|
||||
ConditionVariable(ConditionVariable&&) = delete; ///TODO
|
||||
~ConditionVariable();
|
||||
|
||||
void Wait(NzMutex* mutex);
|
||||
bool Wait(NzMutex* mutex, nzUInt32 timeout);
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
|
||||
private:
|
||||
NzConditionVariableImpl* m_impl;
|
||||
};
|
||||
void Wait(Mutex* mutex);
|
||||
bool Wait(Mutex* mutex, UInt32 timeout);
|
||||
|
||||
ConditionVariable& operator=(const ConditionVariable&) = delete;
|
||||
ConditionVariable& operator=(ConditionVariable&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
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,20 +10,23 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
|
||||
class NAZARA_CORE_API NzCore
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzCore() = delete;
|
||||
~NzCore() = delete;
|
||||
class NAZARA_CORE_API Core
|
||||
{
|
||||
public:
|
||||
Core() = delete;
|
||||
~Core() = delete;
|
||||
|
||||
static bool Initialize();
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsInitialized();
|
||||
static bool IsInitialized();
|
||||
|
||||
static void Uninitialize();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
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,49 +25,57 @@
|
|||
#include <Nazara/Core/ThreadSafetyOff.hpp>
|
||||
#endif
|
||||
|
||||
class NzDirectoryImpl;
|
||||
|
||||
class NAZARA_CORE_API NzDirectory : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzDirectory();
|
||||
NzDirectory(const NzString& dirPath);
|
||||
~NzDirectory();
|
||||
class DirectoryImpl;
|
||||
|
||||
void Close();
|
||||
class NAZARA_CORE_API Directory
|
||||
{
|
||||
public:
|
||||
Directory();
|
||||
Directory(const String& dirPath);
|
||||
Directory(const Directory&) = delete;
|
||||
Directory(Directory&&) = delete; ///TODO
|
||||
~Directory();
|
||||
|
||||
bool Exists() const;
|
||||
void Close();
|
||||
|
||||
NzString GetPath() const;
|
||||
NzString GetPattern() const;
|
||||
NzString GetResultName() const;
|
||||
NzString GetResultPath() const;
|
||||
nzUInt64 GetResultSize() const;
|
||||
bool Exists() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
bool IsResultDirectory() const;
|
||||
String GetPath() const;
|
||||
String GetPattern() const;
|
||||
String GetResultName() const;
|
||||
String GetResultPath() const;
|
||||
UInt64 GetResultSize() const;
|
||||
|
||||
bool NextResult(bool skipDots = true);
|
||||
bool IsOpen() const;
|
||||
bool IsResultDirectory() const;
|
||||
|
||||
bool Open();
|
||||
bool NextResult(bool skipDots = true);
|
||||
|
||||
void SetPath(const NzString& dirPath);
|
||||
void SetPattern(const NzString& pattern);
|
||||
bool Open();
|
||||
|
||||
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 const char* GetCurrentFileRelativeToEngine(const char* currentFile);
|
||||
static bool Remove(const NzString& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const NzString& dirPath);
|
||||
void SetPath(const String& dirPath);
|
||||
void SetPattern(const String& pattern);
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
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 String& dirPath, bool emptyDirectory = false);
|
||||
static bool SetCurrent(const String& dirPath);
|
||||
|
||||
NzString m_dirPath;
|
||||
NzString m_pattern;
|
||||
NzDirectoryImpl* m_impl;
|
||||
};
|
||||
Directory& operator=(const Directory&) = delete;
|
||||
Directory& operator=(Directory&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
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;
|
||||
|
||||
bool IsLoaded() const;
|
||||
class NAZARA_CORE_API DynLib
|
||||
{
|
||||
public:
|
||||
DynLib();
|
||||
DynLib(const DynLib&) = delete;
|
||||
DynLib(DynLib&& lib);
|
||||
~DynLib();
|
||||
|
||||
bool Load(const NzString& libraryPath);
|
||||
void Unload();
|
||||
String GetLastError() const;
|
||||
DynLibFunc GetSymbol(const String& symbol) const;
|
||||
|
||||
NzDynLib& operator=(NzDynLib&& lib);
|
||||
bool IsLoaded() const;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
bool Load(const String& libraryPath);
|
||||
void Unload();
|
||||
|
||||
mutable NzString m_lastError;
|
||||
NzDynLibImpl* m_impl;
|
||||
DynLib& operator=(const DynLib&) = delete;
|
||||
DynLib& operator=(DynLib&& lib);
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
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 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);
|
||||
unsigned int i = 0;
|
||||
unsigned int j = size-1;
|
||||
inline Endianness GetPlatformEndianness()
|
||||
{
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
return Endianness_BigEndian;
|
||||
#elif defined(NAZARA_LITTLE_ENDIAN)
|
||||
return Endianness_LittleEndian;
|
||||
#endif
|
||||
}
|
||||
|
||||
while (i < j)
|
||||
std::swap(bytes[i++], bytes[j--]);
|
||||
}
|
||||
inline void SwapBytes(void* buffer, unsigned int size)
|
||||
{
|
||||
UInt8* bytes = reinterpret_cast<UInt8*>(buffer);
|
||||
unsigned int i = 0;
|
||||
unsigned int j = size-1;
|
||||
|
||||
inline nzEndianness NzGetPlatformEndianness()
|
||||
{
|
||||
#if defined(NAZARA_BIG_ENDIAN)
|
||||
return nzEndianness_BigEndian;
|
||||
#elif defined(NAZARA_LITTLE_ENDIAN)
|
||||
return nzEndianness_LittleEndian;
|
||||
#endif
|
||||
while (i < j)
|
||||
std::swap(bytes[i++], bytes[j--]);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -7,182 +7,185 @@
|
|||
#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_Current = 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_ReadWrite = 0x08, // Ouvre en lecture/écriture
|
||||
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_Max = OpenMode_WriteOnly
|
||||
};
|
||||
|
||||
enum nzParameterType
|
||||
{
|
||||
nzParameterType_Boolean,
|
||||
nzParameterType_Float,
|
||||
nzParameterType_Integer,
|
||||
nzParameterType_None,
|
||||
nzParameterType_Pointer,
|
||||
nzParameterType_String,
|
||||
nzParameterType_Userdata,
|
||||
enum ParameterType
|
||||
{
|
||||
ParameterType_Boolean,
|
||||
ParameterType_Float,
|
||||
ParameterType_Integer,
|
||||
ParameterType_None,
|
||||
ParameterType_Pointer,
|
||||
ParameterType_String,
|
||||
ParameterType_Userdata,
|
||||
|
||||
nzParameterType_Max = nzParameterType_Userdata
|
||||
};
|
||||
ParameterType_Max = ParameterType_Userdata
|
||||
};
|
||||
|
||||
enum nzPlugin
|
||||
{
|
||||
nzPlugin_Assimp,
|
||||
nzPlugin_FreeType
|
||||
};
|
||||
enum Plugin
|
||||
{
|
||||
Plugin_Assimp,
|
||||
Plugin_FreeType
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_Box,
|
||||
nzPrimitiveType_Cone,
|
||||
nzPrimitiveType_Plane,
|
||||
nzPrimitiveType_Sphere,
|
||||
enum PrimitiveType
|
||||
{
|
||||
PrimitiveType_Box,
|
||||
PrimitiveType_Cone,
|
||||
PrimitiveType_Plane,
|
||||
PrimitiveType_Sphere,
|
||||
|
||||
nzPrimitiveType_Max = nzPrimitiveType_Sphere
|
||||
};
|
||||
PrimitiveType_Max = 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,
|
||||
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,
|
||||
|
||||
nzProcessorCap_Max = nzProcessorCap_SSE4a
|
||||
};
|
||||
ProcessorCap_Max = ProcessorCap_SSE4a
|
||||
};
|
||||
|
||||
enum nzProcessorVendor
|
||||
{
|
||||
nzProcessorVendor_Unknown = -1,
|
||||
enum ProcessorVendor
|
||||
{
|
||||
ProcessorVendor_Unknown = -1,
|
||||
|
||||
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,
|
||||
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,
|
||||
|
||||
nzProcessorVendor_Max = nzProcessorVendor_XenHVM
|
||||
};
|
||||
ProcessorVendor_Max = ProcessorVendor_XenHVM
|
||||
};
|
||||
|
||||
enum nzSphereType
|
||||
{
|
||||
nzSphereType_Cubic,
|
||||
nzSphereType_Ico,
|
||||
nzSphereType_UV,
|
||||
enum SphereType
|
||||
{
|
||||
SphereType_Cubic,
|
||||
SphereType_Ico,
|
||||
SphereType_UV,
|
||||
|
||||
nzSphereType_Max = nzSphereType_UV
|
||||
};
|
||||
SphereType_Max = SphereType_UV
|
||||
};
|
||||
|
||||
enum nzStreamOptionFlags
|
||||
{
|
||||
nzStreamOption_None = 0,
|
||||
enum StreamOptionFlags
|
||||
{
|
||||
StreamOption_None = 0,
|
||||
|
||||
nzStreamOption_Text = 0x1,
|
||||
StreamOption_Text = 0x1,
|
||||
|
||||
nzStreamOption_Max = nzStreamOption_Text*2-1
|
||||
};
|
||||
StreamOption_Max = StreamOption_Text*2-1
|
||||
};
|
||||
|
||||
enum nzTernary
|
||||
{
|
||||
nzTernary_False,
|
||||
nzTernary_True,
|
||||
nzTernary_Unknown,
|
||||
enum Ternary
|
||||
{
|
||||
Ternary_False,
|
||||
Ternary_True,
|
||||
Ternary_Unknown,
|
||||
|
||||
nzTernary_Max = nzTernary_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)
|
||||
#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
|
||||
{
|
||||
public:
|
||||
NzError() = delete;
|
||||
~NzError() = delete;
|
||||
class NAZARA_CORE_API Error
|
||||
{
|
||||
public:
|
||||
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 UInt32 GetFlags();
|
||||
static String GetLastError(const char** file = nullptr, unsigned int* line = nullptr, const char** function = nullptr);
|
||||
static unsigned int GetLastSystemErrorCode();
|
||||
static String GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
|
||||
|
||||
static nzUInt32 GetFlags();
|
||||
static NzString 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 void SetFlags(UInt32 flags);
|
||||
|
||||
static void SetFlags(nzUInt32 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 const char* s_lastErrorFunction;
|
||||
static const char* s_lastErrorFile;
|
||||
static unsigned int s_lastErrorLine;
|
||||
};
|
||||
private:
|
||||
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
|
||||
|
|
|
|||
|
|
@ -9,20 +9,27 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
|
||||
class NAZARA_CORE_API NzErrorFlags : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzErrorFlags(nzUInt32 flags, bool replace = false);
|
||||
~NzErrorFlags();
|
||||
class NAZARA_CORE_API ErrorFlags
|
||||
{
|
||||
public:
|
||||
ErrorFlags(UInt32 flags, bool replace = false);
|
||||
ErrorFlags(const ErrorFlags&) = delete;
|
||||
ErrorFlags(ErrorFlags&&) = delete;
|
||||
~ErrorFlags();
|
||||
|
||||
nzUInt32 GetPreviousFlags() const;
|
||||
UInt32 GetPreviousFlags() const;
|
||||
|
||||
void SetFlags(nzUInt32 flags, bool replace = false);
|
||||
void SetFlags(UInt32 flags, bool replace = false);
|
||||
|
||||
private:
|
||||
nzUInt32 m_previousFlags;
|
||||
};
|
||||
ErrorFlags& operator=(const ErrorFlags&) = delete;
|
||||
ErrorFlags& operator=(ErrorFlags&&) = delete;
|
||||
|
||||
private:
|
||||
UInt32 m_previousFlags;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ERRORFLAGS_HPP
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
|
||||
|
|
@ -25,85 +24,90 @@
|
|||
|
||||
#include <ctime>
|
||||
|
||||
class NzFileImpl;
|
||||
|
||||
class NAZARA_CORE_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzFile();
|
||||
NzFile(const NzString& filePath);
|
||||
NzFile(const NzString& filePath, unsigned int openMode);
|
||||
NzFile(NzFile&& file) noexcept;
|
||||
~NzFile();
|
||||
class FileImpl;
|
||||
|
||||
bool Copy(const NzString& newFilePath);
|
||||
void Close();
|
||||
class NAZARA_CORE_API File : public Hashable, public InputStream
|
||||
{
|
||||
public:
|
||||
File();
|
||||
File(const String& filePath);
|
||||
File(const String& filePath, unsigned int openMode);
|
||||
File(const File&) = delete;
|
||||
File(File&& file) noexcept;
|
||||
~File();
|
||||
|
||||
bool Delete();
|
||||
bool Copy(const String& newFilePath);
|
||||
void Close();
|
||||
|
||||
bool EndOfFile() const;
|
||||
bool EndOfStream() const;
|
||||
bool Delete();
|
||||
|
||||
bool Exists() const;
|
||||
bool EndOfFile() const;
|
||||
bool EndOfStream() const;
|
||||
|
||||
void Flush();
|
||||
bool Exists() const;
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
nzUInt64 GetCursorPos() const;
|
||||
NzString GetDirectory() const;
|
||||
NzString GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
NzString GetPath() const;
|
||||
nzUInt64 GetSize() const;
|
||||
void Flush();
|
||||
|
||||
bool IsOpen() const;
|
||||
time_t GetCreationTime() const;
|
||||
UInt64 GetCursorPos() const;
|
||||
String GetDirectory() const;
|
||||
String GetFileName() const;
|
||||
time_t GetLastAccessTime() const;
|
||||
time_t GetLastWriteTime() const;
|
||||
String GetPath() const;
|
||||
UInt64 GetSize() const;
|
||||
|
||||
bool Open(unsigned int openMode = nzOpenMode_Current);
|
||||
bool Open(const NzString& filePath, unsigned int openMode = nzOpenMode_Current);
|
||||
bool IsOpen() const;
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size);
|
||||
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
||||
bool Rename(const NzString& newFilePath);
|
||||
bool Open(unsigned int openMode = OpenMode_Current);
|
||||
bool Open(const String& filePath, unsigned int openMode = OpenMode_Current);
|
||||
|
||||
bool SetCursorPos(nzCursorPosition pos, nzInt64 offset = 0);
|
||||
bool SetCursorPos(nzUInt64 offset);
|
||||
void SetEndianness(nzEndianness endianness);
|
||||
bool SetFile(const NzString& filePath);
|
||||
bool SetOpenMode(unsigned int openMode);
|
||||
std::size_t Read(void* buffer, std::size_t size);
|
||||
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
||||
bool Rename(const String& newFilePath);
|
||||
|
||||
bool Write(const NzByteArray& byteArray);
|
||||
bool Write(const NzString& string);
|
||||
std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count);
|
||||
bool SetCursorPos(CursorPosition pos, Int64 offset = 0);
|
||||
bool SetCursorPos(UInt64 offset);
|
||||
void SetEndianness(Endianness endianness);
|
||||
bool SetFile(const String& filePath);
|
||||
bool SetOpenMode(unsigned int openMode);
|
||||
|
||||
NzFile& operator=(const NzString& filePath);
|
||||
NzFile& operator=(NzFile&& file) noexcept;
|
||||
bool Write(const Nz::ByteArray& byteArray);
|
||||
bool Write(const String& string);
|
||||
std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count);
|
||||
|
||||
static NzString AbsolutePath(const NzString& filePath);
|
||||
static bool Copy(const NzString& sourcePath, const NzString& targetPath);
|
||||
static bool Delete(const NzString& filePath);
|
||||
static bool Exists(const NzString& filePath);
|
||||
static time_t GetCreationTime(const NzString& filePath);
|
||||
static NzString GetDirectory(const NzString& filePath);
|
||||
static time_t GetLastAccessTime(const NzString& filePath);
|
||||
static time_t GetLastWriteTime(const NzString& filePath);
|
||||
static NzHashDigest GetHash(const NzString& filePath, nzHash hash);
|
||||
static NzHashDigest GetHash(const NzString& filePath, NzAbstractHash* hash);
|
||||
static nzUInt64 GetSize(const NzString& filePath);
|
||||
static bool IsAbsolute(const NzString& filePath);
|
||||
static NzString NormalizePath(const NzString& filePath);
|
||||
static NzString NormalizeSeparators(const NzString& filePath);
|
||||
static bool Rename(const NzString& sourcePath, const NzString& targetPath);
|
||||
File& operator=(const String& filePath);
|
||||
File& operator=(const File&) = delete;
|
||||
File& operator=(File&& file) noexcept;
|
||||
|
||||
private:
|
||||
bool FillHash(NzAbstractHash* hash) const;
|
||||
static String AbsolutePath(const String& filePath);
|
||||
static bool Copy(const String& sourcePath, const String& targetPath);
|
||||
static bool Delete(const String& filePath);
|
||||
static bool Exists(const String& filePath);
|
||||
static time_t GetCreationTime(const String& filePath);
|
||||
static String GetDirectory(const String& filePath);
|
||||
static time_t GetLastAccessTime(const String& filePath);
|
||||
static time_t GetLastWriteTime(const String& filePath);
|
||||
static HashDigest GetHash(const String& filePath, HashType hash);
|
||||
static HashDigest GetHash(const String& filePath, AbstractHash* hash);
|
||||
static UInt64 GetSize(const String& filePath);
|
||||
static bool IsAbsolute(const String& filePath);
|
||||
static String NormalizePath(const String& filePath);
|
||||
static String NormalizeSeparators(const String& filePath);
|
||||
static bool Rename(const String& sourcePath, const String& targetPath);
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
private:
|
||||
bool FillHash(AbstractHash* hash) const;
|
||||
|
||||
nzEndianness m_endianness;
|
||||
NzString m_filePath;
|
||||
NzFileImpl* m_impl;
|
||||
unsigned int m_openMode;
|
||||
};
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
Endianness m_endianness;
|
||||
String m_filePath;
|
||||
FileImpl* m_impl;
|
||||
unsigned int m_openMode;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_FILE_HPP
|
||||
|
|
|
|||
|
|
@ -11,47 +11,50 @@
|
|||
|
||||
// Inspiré du code de la SFML par Laurent Gomila
|
||||
|
||||
struct NzFunctor
|
||||
namespace Nz
|
||||
{
|
||||
virtual ~NzFunctor() {}
|
||||
struct Functor
|
||||
{
|
||||
virtual ~Functor() {}
|
||||
|
||||
virtual void Run() = 0;
|
||||
};
|
||||
virtual void Run() = 0;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
struct NzFunctorWithoutArgs : NzFunctor
|
||||
{
|
||||
NzFunctorWithoutArgs(F func);
|
||||
template<typename F>
|
||||
struct FunctorWithoutArgs : Functor
|
||||
{
|
||||
FunctorWithoutArgs(F func);
|
||||
|
||||
void Run();
|
||||
void Run();
|
||||
|
||||
private:
|
||||
F m_func;
|
||||
};
|
||||
private:
|
||||
F m_func;
|
||||
};
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct NzFunctorWithArgs : NzFunctor
|
||||
{
|
||||
NzFunctorWithArgs(F func, Args&&... args);
|
||||
template<typename F, typename... Args>
|
||||
struct FunctorWithArgs : Functor
|
||||
{
|
||||
FunctorWithArgs(F func, Args&&... args);
|
||||
|
||||
void Run();
|
||||
void Run();
|
||||
|
||||
private:
|
||||
F m_func;
|
||||
std::tuple<Args...> m_args;
|
||||
};
|
||||
private:
|
||||
F m_func;
|
||||
std::tuple<Args...> m_args;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct NzMemberWithoutArgs : NzFunctor
|
||||
{
|
||||
NzMemberWithoutArgs(void (C::*func)(), C* object);
|
||||
template<typename C>
|
||||
struct MemberWithoutArgs : Functor
|
||||
{
|
||||
MemberWithoutArgs(void (C::*func)(), C* object);
|
||||
|
||||
void Run();
|
||||
void Run();
|
||||
|
||||
private:
|
||||
void (C::*m_func)();
|
||||
C* m_object;
|
||||
};
|
||||
private:
|
||||
void (C::*m_func)();
|
||||
C* m_object;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Functor.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,41 +4,44 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
template<typename F>
|
||||
NzFunctorWithoutArgs<F>::NzFunctorWithoutArgs(F func) :
|
||||
m_func(func)
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
template<typename F>
|
||||
FunctorWithoutArgs<F>::FunctorWithoutArgs(F func) :
|
||||
m_func(func)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void NzFunctorWithoutArgs<F>::Run()
|
||||
{
|
||||
m_func();
|
||||
}
|
||||
template<typename F>
|
||||
void FunctorWithoutArgs<F>::Run()
|
||||
{
|
||||
m_func();
|
||||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
NzFunctorWithArgs<F, Args...>::NzFunctorWithArgs(F func, Args&&... args) :
|
||||
m_func(func),
|
||||
m_args(std::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
template<typename F, typename... Args>
|
||||
FunctorWithArgs<F, Args...>::FunctorWithArgs(F func, Args&&... args) :
|
||||
m_func(func),
|
||||
m_args(std::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
void NzFunctorWithArgs<F, Args...>::Run()
|
||||
{
|
||||
NzApply(m_func, m_args);
|
||||
}
|
||||
template<typename F, typename... Args>
|
||||
void FunctorWithArgs<F, Args...>::Run()
|
||||
{
|
||||
Apply(m_func, m_args);
|
||||
}
|
||||
|
||||
|
||||
template<typename C>
|
||||
NzMemberWithoutArgs<C>::NzMemberWithoutArgs(void (C::*func)(), C* object) :
|
||||
m_func(func),
|
||||
m_object(object)
|
||||
{
|
||||
}
|
||||
template<typename C>
|
||||
MemberWithoutArgs<C>::MemberWithoutArgs(void (C::*func)(), C* object) :
|
||||
m_func(func),
|
||||
m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
void NzMemberWithoutArgs<C>::Run()
|
||||
{
|
||||
(m_object->*m_func)();
|
||||
template<typename C>
|
||||
void MemberWithoutArgs<C>::Run()
|
||||
{
|
||||
(m_object->*m_func)();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,74 +15,77 @@
|
|||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_CORE_API NzGuillotineBinPack
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
enum FreeRectChoiceHeuristic : int;
|
||||
enum GuillotineSplitHeuristic : int;
|
||||
class NAZARA_CORE_API GuillotineBinPack
|
||||
{
|
||||
public:
|
||||
enum FreeRectChoiceHeuristic : int;
|
||||
enum GuillotineSplitHeuristic : int;
|
||||
|
||||
NzGuillotineBinPack();
|
||||
NzGuillotineBinPack(unsigned int width, unsigned int height);
|
||||
NzGuillotineBinPack(const NzVector2ui& size);
|
||||
NzGuillotineBinPack(const NzGuillotineBinPack&) = default;
|
||||
NzGuillotineBinPack(NzGuillotineBinPack&&) = default;
|
||||
~NzGuillotineBinPack() = default;
|
||||
GuillotineBinPack();
|
||||
GuillotineBinPack(unsigned int width, unsigned int height);
|
||||
GuillotineBinPack(const Vector2ui& size);
|
||||
GuillotineBinPack(const GuillotineBinPack&) = default;
|
||||
GuillotineBinPack(GuillotineBinPack&&) = default;
|
||||
~GuillotineBinPack() = default;
|
||||
|
||||
void Clear();
|
||||
void Clear();
|
||||
|
||||
void Expand(unsigned int newWidth, unsigned newHeight);
|
||||
void Expand(const NzVector2ui& newSize);
|
||||
void Expand(unsigned int newWidth, unsigned newHeight);
|
||||
void Expand(const Vector2ui& newSize);
|
||||
|
||||
void FreeRectangle(const NzRectui& rect);
|
||||
void FreeRectangle(const Rectui& rect);
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
float GetOccupancy() const;
|
||||
NzVector2ui GetSize() const;
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int GetHeight() const;
|
||||
float GetOccupancy() const;
|
||||
Vector2ui GetSize() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
bool Insert(NzRectui* rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(NzRectui* rects, bool* flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(NzRectui* rects, bool* flipped, bool* inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(Rectui* rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(Rectui* rects, bool* flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
bool Insert(Rectui* rects, bool* flipped, bool* inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
|
||||
|
||||
bool MergeFreeRectangles();
|
||||
bool MergeFreeRectangles();
|
||||
|
||||
void Reset();
|
||||
void Reset(unsigned int width, unsigned int height);
|
||||
void Reset(const NzVector2ui& size);
|
||||
void Reset();
|
||||
void Reset(unsigned int width, unsigned int height);
|
||||
void Reset(const Vector2ui& size);
|
||||
|
||||
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
|
||||
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
|
||||
GuillotineBinPack& operator=(const GuillotineBinPack&) = default;
|
||||
GuillotineBinPack& operator=(GuillotineBinPack&&) = default;
|
||||
|
||||
enum FreeRectChoiceHeuristic : int
|
||||
{
|
||||
RectBestAreaFit,
|
||||
RectBestLongSideFit,
|
||||
RectBestShortSideFit,
|
||||
RectWorstAreaFit,
|
||||
RectWorstLongSideFit,
|
||||
RectWorstShortSideFit
|
||||
};
|
||||
enum FreeRectChoiceHeuristic : int
|
||||
{
|
||||
RectBestAreaFit,
|
||||
RectBestLongSideFit,
|
||||
RectBestShortSideFit,
|
||||
RectWorstAreaFit,
|
||||
RectWorstLongSideFit,
|
||||
RectWorstShortSideFit
|
||||
};
|
||||
|
||||
enum GuillotineSplitHeuristic : int
|
||||
{
|
||||
SplitLongerAxis,
|
||||
SplitLongerLeftoverAxis,
|
||||
SplitMaximizeArea,
|
||||
SplitMinimizeArea,
|
||||
SplitShorterAxis,
|
||||
SplitShorterLeftoverAxis
|
||||
};
|
||||
enum GuillotineSplitHeuristic : int
|
||||
{
|
||||
SplitLongerAxis,
|
||||
SplitLongerLeftoverAxis,
|
||||
SplitMaximizeArea,
|
||||
SplitMinimizeArea,
|
||||
SplitShorterAxis,
|
||||
SplitShorterLeftoverAxis
|
||||
};
|
||||
|
||||
private:
|
||||
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
|
||||
void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method);
|
||||
private:
|
||||
void SplitFreeRectAlongAxis(const Rectui& freeRect, const Rectui& placedRect, bool splitHorizontal);
|
||||
void SplitFreeRectByHeuristic(const Rectui& freeRect, const Rectui& placedRect, GuillotineSplitHeuristic method);
|
||||
|
||||
static int ScoreByHeuristic(int width, int height, const NzRectui& freeRect, FreeRectChoiceHeuristic rectChoice);
|
||||
static int ScoreByHeuristic(int width, int height, const Rectui& freeRect, FreeRectChoiceHeuristic rectChoice);
|
||||
|
||||
std::vector<NzRectui> m_freeRectangles;
|
||||
unsigned int m_height;
|
||||
unsigned int m_usedArea;
|
||||
unsigned int m_width;
|
||||
};
|
||||
std::vector<Rectui> m_freeRectangles;
|
||||
unsigned int m_height;
|
||||
unsigned int m_usedArea;
|
||||
unsigned int m_width;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_GUILLOTINEBINPACK_HPP
|
||||
|
|
|
|||
|
|
@ -11,25 +11,31 @@
|
|||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
class NAZARA_CORE_API NzHardwareInfo
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
static void Cpuid(nzUInt32 functionId, nzUInt32 subFunctionId, nzUInt32 result[4]);
|
||||
class NAZARA_CORE_API HardwareInfo
|
||||
{
|
||||
public:
|
||||
HardwareInfo() = delete;
|
||||
~HardwareInfo() = delete;
|
||||
|
||||
static NzString GetProcessorBrandString();
|
||||
static unsigned int GetProcessorCount();
|
||||
static nzProcessorVendor GetProcessorVendor();
|
||||
static NzString GetProcessorVendorName();
|
||||
static nzUInt64 GetTotalMemory();
|
||||
static void Cpuid(UInt32 functionId, UInt32 subFunctionId, UInt32 result[4]);
|
||||
|
||||
static bool HasCapability(nzProcessorCap capability);
|
||||
static String GetProcessorBrandString();
|
||||
static unsigned int GetProcessorCount();
|
||||
static ProcessorVendor GetProcessorVendor();
|
||||
static String GetProcessorVendorName();
|
||||
static UInt64 GetTotalMemory();
|
||||
|
||||
static bool Initialize();
|
||||
static bool HasCapability(ProcessorCap capability);
|
||||
|
||||
static bool IsCpuidSupported();
|
||||
static bool IsInitialized();
|
||||
static bool Initialize();
|
||||
|
||||
static void Uninitialize();
|
||||
};
|
||||
static bool IsCpuidSupported();
|
||||
static bool IsInitialized();
|
||||
|
||||
static void Uninitialize();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HARDWAREINFO_HPP
|
||||
|
|
|
|||
|
|
@ -11,19 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/Hashable.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
|
||||
class NAZARA_CORE_API NzHash : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHash(nzHash hash);
|
||||
NzHash(NzAbstractHash* hashImpl);
|
||||
~NzHash();
|
||||
class NAZARA_CORE_API Hash
|
||||
{
|
||||
public:
|
||||
Hash(HashType hash);
|
||||
Hash(AbstractHash* hashImpl);
|
||||
Hash(const Hash&) = delete;
|
||||
Hash(Hash&&) = delete; ///TODO
|
||||
~Hash();
|
||||
|
||||
NzHashDigest Hash(const NzHashable& hashable);
|
||||
HashDigest Process(const Hashable& hashable);
|
||||
|
||||
private:
|
||||
NzAbstractHash* m_impl;
|
||||
};
|
||||
Hash& operator=(const Hash&) = delete;
|
||||
Hash& operator=(Hash&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
AbstractHash* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
struct NzHashCRC32_state;
|
||||
|
||||
class NAZARA_CORE_API NzHashCRC32 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashCRC32(nzUInt32 polynomial = 0x04c11db7);
|
||||
virtual ~NzHashCRC32();
|
||||
struct HashCRC32_state;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashCRC32 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashCRC32(UInt32 polynomial = 0x04c11db7);
|
||||
virtual ~HashCRC32();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
NzHashCRC32_state* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
HashCRC32_state* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_CRC32_HPP
|
||||
|
|
|
|||
|
|
@ -12,23 +12,26 @@
|
|||
#include <Nazara/Core/HashDigest.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
struct NzHashFletcher16_state;
|
||||
|
||||
class NAZARA_CORE_API NzHashFletcher16 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashFletcher16();
|
||||
virtual ~NzHashFletcher16();
|
||||
struct HashFletcher16_state;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashFletcher16 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashFletcher16();
|
||||
virtual ~HashFletcher16();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
NzHashFletcher16_state* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
HashFletcher16_state* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_FLETCHER16_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
struct NzHashMD5_state;
|
||||
|
||||
class NAZARA_CORE_API NzHashMD5 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashMD5();
|
||||
virtual ~NzHashMD5();
|
||||
struct HashMD5_state;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashMD5 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashMD5();
|
||||
virtual ~HashMD5();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
NzHashMD5_state* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
HashMD5_state* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_MD5_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
union SHA_CTX;
|
||||
|
||||
class NAZARA_CORE_API NzHashSHA1 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashSHA1();
|
||||
virtual ~NzHashSHA1();
|
||||
union SHA_CTX;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashSHA1 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashSHA1();
|
||||
virtual ~HashSHA1();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_SHA1_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
union SHA_CTX;
|
||||
|
||||
class NAZARA_CORE_API NzHashSHA224 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashSHA224();
|
||||
virtual ~NzHashSHA224();
|
||||
union SHA_CTX;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashSHA224 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashSHA224();
|
||||
virtual ~HashSHA224();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_SHA224_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
union SHA_CTX;
|
||||
|
||||
class NAZARA_CORE_API NzHashSHA256 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashSHA256();
|
||||
virtual ~NzHashSHA256();
|
||||
union SHA_CTX;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashSHA256 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashSHA256();
|
||||
virtual ~HashSHA256();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_SHA256_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
union SHA_CTX;
|
||||
|
||||
class NAZARA_CORE_API NzHashSHA384 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashSHA384();
|
||||
virtual ~NzHashSHA384();
|
||||
union SHA_CTX;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashSHA384 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashSHA384();
|
||||
virtual ~HashSHA384();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_SHA384_HPP
|
||||
|
|
|
|||
|
|
@ -11,23 +11,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
union SHA_CTX;
|
||||
|
||||
class NAZARA_CORE_API NzHashSHA512 : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashSHA512();
|
||||
virtual ~NzHashSHA512();
|
||||
union SHA_CTX;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashSHA512 : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashSHA512();
|
||||
virtual ~HashSHA512();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
SHA_CTX* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_SHA512_HPP
|
||||
|
|
|
|||
|
|
@ -9,23 +9,26 @@
|
|||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/HashDigest.hpp>
|
||||
|
||||
struct NzHashWhirlpool_state;
|
||||
|
||||
class NAZARA_CORE_API NzHashWhirlpool : public NzAbstractHash
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashWhirlpool();
|
||||
virtual ~NzHashWhirlpool();
|
||||
struct HashWhirlpool_state;
|
||||
|
||||
void Append(const nzUInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
NzHashDigest End();
|
||||
class NAZARA_CORE_API HashWhirlpool : public AbstractHash
|
||||
{
|
||||
public:
|
||||
HashWhirlpool();
|
||||
virtual ~HashWhirlpool();
|
||||
|
||||
static unsigned int GetDigestLength();
|
||||
static NzString GetHashName();
|
||||
void Append(const UInt8* data, unsigned int len);
|
||||
void Begin();
|
||||
HashDigest End();
|
||||
|
||||
private:
|
||||
NzHashWhirlpool_state* m_state;
|
||||
};
|
||||
static unsigned int GetDigestLength();
|
||||
static String GetHashName();
|
||||
|
||||
private:
|
||||
HashWhirlpool_state* m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASH_WHIRLPOOL_HPP
|
||||
|
|
|
|||
|
|
@ -13,41 +13,44 @@
|
|||
#include <Nazara/Core/String.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
class NAZARA_CORE_API NzHashDigest
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzHashDigest();
|
||||
NzHashDigest(const NzString& hashName, const nzUInt8* digest, unsigned int length);
|
||||
NzHashDigest(const NzHashDigest& rhs);
|
||||
NzHashDigest(NzHashDigest&& rhs) noexcept;
|
||||
~NzHashDigest();
|
||||
class NAZARA_CORE_API HashDigest
|
||||
{
|
||||
public:
|
||||
HashDigest();
|
||||
HashDigest(const String& hashName, const UInt8* digest, unsigned int length);
|
||||
HashDigest(const HashDigest& rhs);
|
||||
HashDigest(HashDigest&& rhs) noexcept;
|
||||
~HashDigest();
|
||||
|
||||
bool IsValid() const;
|
||||
bool IsValid() const;
|
||||
|
||||
const nzUInt8* GetDigest() const;
|
||||
unsigned int GetDigestLength() const;
|
||||
NzString GetHashName() const;
|
||||
const UInt8* GetDigest() const;
|
||||
unsigned int GetDigestLength() const;
|
||||
String GetHashName() const;
|
||||
|
||||
NzString ToHex() const;
|
||||
String ToHex() const;
|
||||
|
||||
nzUInt8 operator[](unsigned int pos) const;
|
||||
UInt8 operator[](unsigned int pos) const;
|
||||
|
||||
NzHashDigest& operator=(const NzHashDigest& rhs);
|
||||
NzHashDigest& operator=(NzHashDigest&& rhs) noexcept;
|
||||
HashDigest& operator=(const HashDigest& rhs);
|
||||
HashDigest& operator=(HashDigest&& rhs) noexcept;
|
||||
|
||||
bool operator==(const NzHashDigest& rhs) const;
|
||||
bool operator!=(const NzHashDigest& rhs) const;
|
||||
bool operator<(const NzHashDigest& rhs) const;
|
||||
bool operator<=(const NzHashDigest& rhs) const;
|
||||
bool operator>(const NzHashDigest& rhs) const;
|
||||
bool operator>=(const NzHashDigest& rhs) const;
|
||||
bool operator==(const HashDigest& rhs) const;
|
||||
bool operator!=(const HashDigest& rhs) const;
|
||||
bool operator<(const HashDigest& rhs) const;
|
||||
bool operator<=(const HashDigest& rhs) const;
|
||||
bool operator>(const HashDigest& rhs) const;
|
||||
bool operator>=(const HashDigest& rhs) const;
|
||||
|
||||
NAZARA_CORE_API friend std::ostream& operator<<(std::ostream& out, const NzHashDigest& string);
|
||||
NAZARA_CORE_API friend std::ostream& operator<<(std::ostream& out, const HashDigest& string);
|
||||
|
||||
private:
|
||||
NzString m_hashName;
|
||||
nzUInt8* m_digest;
|
||||
unsigned int m_digestLength;
|
||||
};
|
||||
private:
|
||||
String m_hashName;
|
||||
UInt8* m_digest;
|
||||
unsigned int m_digestLength;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HASHDIGEST_HPP
|
||||
|
|
|
|||
|
|
@ -10,22 +10,30 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
|
||||
class NzAbstractHash;
|
||||
class NzHashDigest;
|
||||
|
||||
class NAZARA_CORE_API NzHashable
|
||||
namespace Nz
|
||||
{
|
||||
friend class NzHash;
|
||||
class AbstractHash;
|
||||
class HashDigest;
|
||||
|
||||
public:
|
||||
NzHashable() = default;
|
||||
virtual ~NzHashable();
|
||||
class NAZARA_CORE_API Hashable
|
||||
{
|
||||
friend class Hash;
|
||||
|
||||
NzHashDigest GetHash(nzHash hash) const;
|
||||
NzHashDigest GetHash(NzAbstractHash* impl) const;
|
||||
public:
|
||||
Hashable() = default;
|
||||
Hashable(const Hashable&) = default;
|
||||
Hashable(Hashable&&) = default;
|
||||
virtual ~Hashable();
|
||||
|
||||
private:
|
||||
virtual bool FillHash(NzAbstractHash* impl) const = 0;
|
||||
};
|
||||
HashDigest GetHash(HashType hash) const;
|
||||
HashDigest GetHash(AbstractHash* impl) const;
|
||||
|
||||
Hashable& operator=(const Hashable&) = default;
|
||||
Hashable& operator=(Hashable&&) = default;
|
||||
|
||||
private:
|
||||
virtual bool FillHash(AbstractHash* impl) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HASHABLE_HPP_INCLUDED
|
||||
|
|
|
|||
|
|
@ -9,22 +9,30 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
class NzInitializer
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzInitializer(bool initialize = true);
|
||||
~NzInitializer();
|
||||
template<typename... Args>
|
||||
class Initializer
|
||||
{
|
||||
public:
|
||||
Initializer(bool initialize = true);
|
||||
Initializer(const Initializer&) = delete;
|
||||
Initializer(Initializer&&) = delete; ///TODO
|
||||
~Initializer();
|
||||
|
||||
bool Initialize();
|
||||
bool IsInitialized() const;
|
||||
void Uninitialize();
|
||||
bool Initialize();
|
||||
bool IsInitialized() const;
|
||||
void Uninitialize();
|
||||
|
||||
operator bool() const;
|
||||
operator bool() const;
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
};
|
||||
Initializer& operator=(const Initializer&) = delete;
|
||||
Initializer& operator=(Initializer&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Initializer.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,84 +4,91 @@
|
|||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename...> struct NzImplInitializer;
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
struct NzImplInitializer<T, Rest...>
|
||||
namespace Nz
|
||||
{
|
||||
static bool Init()
|
||||
namespace Detail
|
||||
{
|
||||
if (T::Initialize())
|
||||
template<typename...> struct Initializer;
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
struct Initializer<T, Rest...>
|
||||
{
|
||||
if (NzImplInitializer<Rest...>::Init())
|
||||
return true;
|
||||
else
|
||||
static bool Init()
|
||||
{
|
||||
if (T::Initialize())
|
||||
{
|
||||
if (Initializer<Rest...>::Init())
|
||||
return true;
|
||||
else
|
||||
T::Uninitialize();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Uninit()
|
||||
{
|
||||
Initializer<Rest...>::Uninit();
|
||||
T::Uninitialize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return false;
|
||||
template<>
|
||||
struct Initializer<>
|
||||
{
|
||||
static bool Init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Uninit()
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void Uninit()
|
||||
|
||||
template<typename... Args>
|
||||
Initializer<Args...>::Initializer(bool initialize) :
|
||||
m_initialized(false)
|
||||
{
|
||||
NzImplInitializer<Rest...>::Uninit();
|
||||
T::Uninitialize();
|
||||
if (initialize)
|
||||
Initialize();
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct NzImplInitializer<>
|
||||
{
|
||||
static bool Init()
|
||||
template<typename... Args>
|
||||
Initializer<Args...>::~Initializer()
|
||||
{
|
||||
return true;
|
||||
Uninitialize();
|
||||
}
|
||||
|
||||
static void Uninit()
|
||||
template<typename... Args>
|
||||
bool Initializer<Args...>::Initialize()
|
||||
{
|
||||
if (!m_initialized)
|
||||
m_initialized = Detail::Initializer<Args...>::Init();
|
||||
|
||||
return m_initialized;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
NzInitializer<Args...>::NzInitializer(bool initialize) :
|
||||
m_initialized(false)
|
||||
{
|
||||
if (initialize)
|
||||
Initialize();
|
||||
}
|
||||
template<typename... Args>
|
||||
bool Initializer<Args...>::IsInitialized() const
|
||||
{
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzInitializer<Args...>::~NzInitializer()
|
||||
{
|
||||
Uninitialize();
|
||||
}
|
||||
template<typename... Args>
|
||||
void Initializer<Args...>::Uninitialize()
|
||||
{
|
||||
if (m_initialized)
|
||||
Detail::Initializer<Args...>::Uninit();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
bool NzInitializer<Args...>::Initialize()
|
||||
{
|
||||
if (!m_initialized)
|
||||
m_initialized = NzImplInitializer<Args...>::Init();
|
||||
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
bool NzInitializer<Args...>::IsInitialized() const
|
||||
{
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void NzInitializer<Args...>::Uninitialize()
|
||||
{
|
||||
if (m_initialized)
|
||||
NzImplInitializer<Args...>::Uninit();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzInitializer<Args...>::operator bool() const
|
||||
{
|
||||
return IsInitialized();
|
||||
template<typename... Args>
|
||||
Initializer<Args...>::operator bool() const
|
||||
{
|
||||
return IsInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -10,17 +10,20 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
class NAZARA_CORE_API NzInputStream : public NzStream
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
virtual ~NzInputStream();
|
||||
class NAZARA_CORE_API InputStream : public Stream
|
||||
{
|
||||
public:
|
||||
virtual ~InputStream();
|
||||
|
||||
virtual bool EndOfStream() const = 0;
|
||||
virtual bool EndOfStream() const = 0;
|
||||
|
||||
virtual nzUInt64 GetSize() const = 0;
|
||||
virtual UInt64 GetSize() const = 0;
|
||||
|
||||
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||
virtual NzString ReadLine(unsigned int lineSize = 0);
|
||||
};
|
||||
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||
virtual String ReadLine(unsigned int lineSize = 0);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_INPUTSTREAM_HPP
|
||||
|
|
|
|||
|
|
@ -9,16 +9,19 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzMutex;
|
||||
|
||||
class NAZARA_CORE_API NzLockGuard
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzLockGuard(NzMutex& mutex);
|
||||
~NzLockGuard();
|
||||
class Mutex;
|
||||
|
||||
private:
|
||||
NzMutex& m_mutex;
|
||||
};
|
||||
class NAZARA_CORE_API LockGuard
|
||||
{
|
||||
public:
|
||||
LockGuard(Mutex& mutex);
|
||||
~LockGuard();
|
||||
|
||||
private:
|
||||
Mutex& m_mutex;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_LOCKGUARD_HPP
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG
|
||||
|
|
@ -24,41 +23,49 @@
|
|||
#define NazaraDebug(txt)
|
||||
#endif
|
||||
|
||||
#define NazaraLog NzLog::Instance()
|
||||
#define NazaraLog Nz::Log::Instance()
|
||||
#define NazaraNotice(txt) NazaraLog->Write(txt)
|
||||
|
||||
class NzFile;
|
||||
|
||||
class NAZARA_CORE_API NzLog : NzNonCopyable
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
void Enable(bool enable);
|
||||
void EnableAppend(bool enable);
|
||||
void EnableDateTime(bool enable);
|
||||
class File;
|
||||
|
||||
NzString GetFile() const;
|
||||
class NAZARA_CORE_API Log
|
||||
{
|
||||
public:
|
||||
void Enable(bool enable);
|
||||
void EnableAppend(bool enable);
|
||||
void EnableDateTime(bool enable);
|
||||
|
||||
bool IsEnabled() const;
|
||||
String GetFile() const;
|
||||
|
||||
void SetFile(const NzString& filePath);
|
||||
bool IsEnabled() const;
|
||||
|
||||
void Write(const NzString& string);
|
||||
void WriteError(nzErrorType type, const NzString& error);
|
||||
void WriteError(nzErrorType type, const NzString& error, unsigned int line, const NzString& file, const NzString& func);
|
||||
void SetFile(const String& filePath);
|
||||
|
||||
static NzLog* Instance();
|
||||
void Write(const String& string);
|
||||
void WriteError(ErrorType type, const String& error);
|
||||
void WriteError(ErrorType type, const String& error, unsigned int line, const String& file, const String& func);
|
||||
|
||||
private:
|
||||
NzLog();
|
||||
~NzLog();
|
||||
static Log* Instance();
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
private:
|
||||
Log();
|
||||
Log(const Log&) = delete;
|
||||
Log(Log&&) = delete;
|
||||
~Log();
|
||||
|
||||
NzString m_filePath;
|
||||
NzFile* m_file;
|
||||
bool m_append;
|
||||
bool m_enabled;
|
||||
bool m_writeTime;
|
||||
};
|
||||
Log& operator=(const Log&) = delete;
|
||||
Log& operator=(Log&&) = delete;
|
||||
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
String m_filePath;
|
||||
File* m_file;
|
||||
bool m_append;
|
||||
bool m_enabled;
|
||||
bool m_writeTime;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_LOGGER_HPP
|
||||
|
|
|
|||
|
|
@ -9,11 +9,14 @@
|
|||
|
||||
#include <cstddef>
|
||||
|
||||
void NzOperatorDelete(void* ptr);
|
||||
void* NzOperatorNew(std::size_t size);
|
||||
namespace Nz
|
||||
{
|
||||
void OperatorDelete(void* ptr);
|
||||
void* OperatorNew(std::size_t size);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* NzPlacementNew(void* ptr, Args&&... args);
|
||||
template<typename T, typename... Args>
|
||||
T* PlacementNew(void* ptr, Args&&... args);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.inl>
|
||||
|
||||
|
|
|
|||
|
|
@ -14,28 +14,31 @@
|
|||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline void NzOperatorDelete(void* ptr)
|
||||
namespace Nz
|
||||
{
|
||||
#if NAZARA_CORE_MANAGE_MEMORY
|
||||
NzMemoryManager::Free(ptr);
|
||||
#else
|
||||
operator delete(ptr);
|
||||
#endif
|
||||
}
|
||||
inline void OperatorDelete(void* ptr)
|
||||
{
|
||||
#if NAZARA_CORE_MANAGE_MEMORY
|
||||
MemoryManager::Free(ptr);
|
||||
#else
|
||||
operator delete(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void* NzOperatorNew(std::size_t size)
|
||||
{
|
||||
#if NAZARA_CORE_MANAGE_MEMORY
|
||||
return NzMemoryManager::Allocate(size);
|
||||
#else
|
||||
return operator new(size);
|
||||
#endif
|
||||
}
|
||||
inline void* OperatorNew(std::size_t size)
|
||||
{
|
||||
#if NAZARA_CORE_MANAGE_MEMORY
|
||||
return MemoryManager::Allocate(size);
|
||||
#else
|
||||
return operator new(size);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* NzPlacementNew(void* ptr, Args&&... args)
|
||||
{
|
||||
return new (ptr) T(std::forward<Args>(args)...);
|
||||
template<typename T, typename... Args>
|
||||
T* PlacementNew(void* ptr, Args&&... args)
|
||||
{
|
||||
return new (ptr) T(std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue