Fully replace listener system by signals

Former-commit-id: 032dfddd12cc3a792c71426148c758ffac3621f9
This commit is contained in:
Lynix 2015-06-07 20:42:41 +02:00
parent 0f4cf3c910
commit a069b105e6
63 changed files with 291 additions and 606 deletions

View File

@ -13,11 +13,11 @@
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp> #include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp> #include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceManager.hpp> #include <Nazara/Core/ResourceManager.hpp>
#include <Nazara/Core/Signal.hpp>
struct NzSoundBufferParams struct NzSoundBufferParams
{ {
@ -29,10 +29,8 @@ struct NzSoundBufferParams
class NzSound; class NzSound;
class NzSoundBuffer; class NzSoundBuffer;
using NzSoundBufferConstListener = NzObjectListenerWrapper<const NzSoundBuffer>;
using NzSoundBufferConstRef = NzObjectRef<const NzSoundBuffer>; using NzSoundBufferConstRef = NzObjectRef<const NzSoundBuffer>;
using NzSoundBufferLibrary = NzObjectLibrary<NzSoundBuffer>; using NzSoundBufferLibrary = NzObjectLibrary<NzSoundBuffer>;
using NzSoundBufferListener = NzObjectListenerWrapper<NzSoundBuffer>;
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>; using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
using NzSoundBufferManager = NzResourceManager<NzSoundBuffer, NzSoundBufferParams>; using NzSoundBufferManager = NzResourceManager<NzSoundBuffer, NzSoundBufferParams>;
using NzSoundBufferRef = NzObjectRef<NzSoundBuffer>; using NzSoundBufferRef = NzObjectRef<NzSoundBuffer>;
@ -70,6 +68,10 @@ class NAZARA_API NzSoundBuffer : public NzRefCounted, public NzResource, NzNonCo
static bool IsFormatSupported(nzAudioFormat format); static bool IsFormatSupported(nzAudioFormat format);
template<typename... Args> static NzSoundBufferRef New(Args&&... args); template<typename... Args> static NzSoundBufferRef New(Args&&... args);
// Signals:
NazaraSignal(OnSoundBufferDestroy, const NzSoundBuffer*); //< Args: me
NazaraSignal(OnSoundBufferRelease, const NzSoundBuffer*); //< Args: me
private: private:
unsigned int GetOpenALBuffer() const; unsigned int GetOpenALBuffer() const;

View File

@ -64,8 +64,6 @@
#include <Nazara/Core/Mutex.hpp> #include <Nazara/Core/Mutex.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/OffsetOf.hpp> #include <Nazara/Core/OffsetOf.hpp>
#include <Nazara/Core/ParameterList.hpp> #include <Nazara/Core/ParameterList.hpp>

View File

@ -1,26 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OBJECTLISTENER_HPP
#define NAZARA_OBJECTLISTENER_HPP
#include <Nazara/Prerequesites.hpp>
class NzRefCounted;
class NAZARA_API NzObjectListener
{
public:
NzObjectListener() = default;
virtual ~NzObjectListener();
virtual bool OnObjectCreated(const NzRefCounted* object, int index);
virtual bool OnObjectDestroy(const NzRefCounted* object, int index);
virtual bool OnObjectModified(const NzRefCounted* object, int index, unsigned int code);
virtual void OnObjectReleased(const NzRefCounted* object, int index);
};
#endif // NAZARA_OBJECTLISTENER_HPP

View File

@ -1,45 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OBJECTLISTENERWRAPPER_HPP
#define NAZARA_OBJECTLISTENERWRAPPER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <type_traits>
template<typename T>
class NzObjectListenerWrapper
{
static_assert(std::is_base_of<NzRefCounted, T>::value, "ObjListenerWrapper should only be used with RefCounted-derived type");
public:
NzObjectListenerWrapper(NzObjectListener* listener, int index = 0, T* object = nullptr);
NzObjectListenerWrapper(const NzObjectListenerWrapper& listener);
NzObjectListenerWrapper(NzObjectListenerWrapper&& listener);
~NzObjectListenerWrapper();
bool IsValid() const;
void Reset(T* object = nullptr);
operator bool() const;
operator T*() const;
T* operator->() const;
NzObjectListenerWrapper& operator=(T* object);
NzObjectListenerWrapper& operator=(const NzObjectListenerWrapper& listener);
NzObjectListenerWrapper& operator=(NzObjectListenerWrapper&& listener);
private:
T* m_object;
NzObjectListener* m_listener;
int m_index;
};
#include <Nazara/Core/ObjectListenerWrapper.inl>
#endif // NAZARA_OBJECTLISTENERWRAPPER_HPP

View File

@ -1,108 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Debug.hpp>
template<typename T>
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(NzObjectListener* listener, int index, T* object) :
m_object(nullptr),
m_listener(listener),
m_index(index)
{
Reset(object);
}
template<typename T>
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(const NzObjectListenerWrapper& listener) :
m_object(nullptr),
m_listener(listener.m_listener),
m_index(listener.m_index)
{
Reset(listener.m_object);
}
template<typename T>
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(NzObjectListenerWrapper&& listener) :
m_object(listener.m_object),
m_listener(listener.m_listener),
m_index(listener.m_index)
{
listener.m_object = nullptr;
}
template<typename T>
NzObjectListenerWrapper<T>::~NzObjectListenerWrapper()
{
Reset(nullptr);
}
template<typename T>
bool NzObjectListenerWrapper<T>::IsValid() const
{
return m_object != nullptr;
}
template<typename T>
void NzObjectListenerWrapper<T>::Reset(T* object)
{
if (object)
object->AddObjectListener(m_listener, m_index);
if (m_object)
m_object->RemoveObjectListener(m_listener);
m_object = object;
}
template<typename T>
NzObjectListenerWrapper<T>::operator bool() const
{
return IsValid();
}
template<typename T>
NzObjectListenerWrapper<T>::operator T*() const
{
return m_object;
}
template<typename T>
T* NzObjectListenerWrapper<T>::operator->() const
{
return m_object;
}
template<typename T>
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(T* object)
{
Reset(object);
return *this;
}
template<typename T>
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(const NzObjectListenerWrapper& listener)
{
m_index = listener.m_index;
m_listener = listener.m_listener;
Reset(listener.m_object);
return *this;
}
template<typename T>
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(NzObjectListenerWrapper&& listener)
{
Reset();
m_index = listener.m_index;
m_listener = listener.m_listener;
m_object = listener.m_object;
listener.m_object = nullptr;
return *this;
}
#include <Nazara/Core/DebugOff.hpp>

View File

@ -17,45 +17,30 @@
#include <Nazara/Core/ThreadSafetyOff.hpp> #include <Nazara/Core/ThreadSafetyOff.hpp>
#endif #endif
class NzObjectListener;
class NAZARA_API NzRefCounted class NAZARA_API NzRefCounted
{ {
public: public:
NzRefCounted(bool persistent = true); NzRefCounted(bool persistent = true);
NzRefCounted(const NzRefCounted&) = delete; NzRefCounted(const NzRefCounted&) = delete;
NzRefCounted(NzRefCounted&&) = delete; NzRefCounted(NzRefCounted&&) = default;
virtual ~NzRefCounted(); virtual ~NzRefCounted();
void AddObjectListener(NzObjectListener* listener, int index = 0) const;
void AddReference() const; void AddReference() const;
unsigned int GetReferenceCount() const; unsigned int GetReferenceCount() const;
bool IsPersistent() const; bool IsPersistent() const;
void RemoveObjectListener(NzObjectListener* listener) const;
bool RemoveReference() const; bool RemoveReference() const;
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false); bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
NzRefCounted& operator=(const NzRefCounted&) = delete; NzRefCounted& operator=(const NzRefCounted&) = delete;
NzRefCounted& operator=(NzRefCounted&&) = delete; NzRefCounted& operator=(NzRefCounted&&) = default;
protected:
void NotifyCreated();
void NotifyDestroy();
void NotifyModified(unsigned int code);
private: private:
using ObjectListenerMap = std::unordered_map<NzObjectListener*, std::pair<int, unsigned int>>; std::atomic_bool m_persistent;
NazaraMutexAttrib(m_mutex, mutable)
mutable ObjectListenerMap m_objectListeners;
std::atomic_bool m_persistent;
mutable std::atomic_uint m_referenceCount; mutable std::atomic_uint m_referenceCount;
bool m_objectListenersLocked;
}; };
#endif // NAZARA_RESOURCE_HPP #endif // NAZARA_RESOURCE_HPP

View File

@ -9,7 +9,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp> #include <Nazara/Core/Color.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Graphics/AbstractRenderQueue.hpp> #include <Nazara/Graphics/AbstractRenderQueue.hpp>
#include <Nazara/Graphics/Material.hpp> #include <Nazara/Graphics/Material.hpp>
#include <Nazara/Math/Box.hpp> #include <Nazara/Math/Box.hpp>

View File

@ -9,7 +9,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp> #include <Nazara/Core/Color.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Graphics/AbstractRenderQueue.hpp> #include <Nazara/Graphics/AbstractRenderQueue.hpp>
#include <Nazara/Graphics/Material.hpp> #include <Nazara/Graphics/Material.hpp>
#include <Nazara/Math/Box.hpp> #include <Nazara/Math/Box.hpp>

View File

@ -10,7 +10,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp> #include <Nazara/Core/Color.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp> #include <Nazara/Core/Resource.hpp>
@ -39,10 +38,8 @@ struct NAZARA_API NzMaterialParams
class NzMaterial; class NzMaterial;
using NzMaterialConstListener = NzObjectListenerWrapper<const NzMaterial>;
using NzMaterialConstRef = NzObjectRef<const NzMaterial>; using NzMaterialConstRef = NzObjectRef<const NzMaterial>;
using NzMaterialLibrary = NzObjectLibrary<NzMaterial>; using NzMaterialLibrary = NzObjectLibrary<NzMaterial>;
using NzMaterialListener = NzObjectListenerWrapper<NzMaterial>;
using NzMaterialLoader = NzResourceLoader<NzMaterial, NzMaterialParams>; using NzMaterialLoader = NzResourceLoader<NzMaterial, NzMaterialParams>;
using NzMaterialManager = NzResourceManager<NzMaterial, NzMaterialParams>; using NzMaterialManager = NzResourceManager<NzMaterial, NzMaterialParams>;
using NzMaterialRef = NzObjectRef<NzMaterial>; using NzMaterialRef = NzObjectRef<NzMaterial>;
@ -145,6 +142,7 @@ class NAZARA_API NzMaterial : public NzRefCounted, public NzResource
// Signals // Signals
NazaraSignal(OnMaterialRelease, const NzMaterial*); //< Args: me NazaraSignal(OnMaterialRelease, const NzMaterial*); //< Args: me
NazaraSignal(OnMaterialReset, const NzMaterial*); //< Args: me
private: private:
struct ShaderInstance struct ShaderInstance

View File

@ -9,18 +9,16 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
class NzParticleController; class NzParticleController;
class NzParticleMapper; class NzParticleMapper;
class NzParticleSystem; class NzParticleSystem;
using NzParticleControllerConstListener = NzObjectListenerWrapper<const NzParticleController>;
using NzParticleControllerConstRef = NzObjectRef<const NzParticleController>; using NzParticleControllerConstRef = NzObjectRef<const NzParticleController>;
using NzParticleControllerLibrary = NzObjectLibrary<NzParticleController>; using NzParticleControllerLibrary = NzObjectLibrary<NzParticleController>;
using NzParticleControllerListener = NzObjectListenerWrapper<NzParticleController>;
using NzParticleControllerRef = NzObjectRef<NzParticleController>; using NzParticleControllerRef = NzObjectRef<NzParticleController>;
class NAZARA_API NzParticleController : public NzRefCounted class NAZARA_API NzParticleController : public NzRefCounted
@ -35,6 +33,9 @@ class NAZARA_API NzParticleController : public NzRefCounted
virtual void Apply(NzParticleSystem& system, NzParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; virtual void Apply(NzParticleSystem& system, NzParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
// Signals:
NazaraSignal(OnParticleControllerRelease, const NzParticleController*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -9,18 +9,16 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/Enums.hpp> #include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
class NzParticleDeclaration; class NzParticleDeclaration;
using NzParticleDeclarationConstListener = NzObjectListenerWrapper<const NzParticleDeclaration>;
using NzParticleDeclarationConstRef = NzObjectRef<const NzParticleDeclaration>; using NzParticleDeclarationConstRef = NzObjectRef<const NzParticleDeclaration>;
using NzParticleDeclarationLibrary = NzObjectLibrary<NzParticleDeclaration>; using NzParticleDeclarationLibrary = NzObjectLibrary<NzParticleDeclaration>;
using NzParticleDeclarationListener = NzObjectListenerWrapper<NzParticleDeclaration>;
using NzParticleDeclarationRef = NzObjectRef<NzParticleDeclaration>; using NzParticleDeclarationRef = NzObjectRef<NzParticleDeclaration>;
class NAZARA_API NzParticleDeclaration : public NzRefCounted class NAZARA_API NzParticleDeclaration : public NzRefCounted
@ -46,6 +44,9 @@ class NAZARA_API NzParticleDeclaration : public NzRefCounted
static NzParticleDeclaration* Get(nzParticleLayout layout); static NzParticleDeclaration* Get(nzParticleLayout layout);
static bool IsTypeSupported(nzComponentType type); static bool IsTypeSupported(nzComponentType type);
// Signals
NazaraSignal(OnParticleDeclarationRelease, const NzParticleDeclaration*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -9,18 +9,16 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
class NzParticleGenerator; class NzParticleGenerator;
class NzParticleMapper; class NzParticleMapper;
class NzParticleSystem; class NzParticleSystem;
using NzParticleGeneratorConstListener = NzObjectListenerWrapper<const NzParticleGenerator>;
using NzParticleGeneratorConstRef = NzObjectRef<const NzParticleGenerator>; using NzParticleGeneratorConstRef = NzObjectRef<const NzParticleGenerator>;
using NzParticleGeneratorLibrary = NzObjectLibrary<NzParticleGenerator>; using NzParticleGeneratorLibrary = NzObjectLibrary<NzParticleGenerator>;
using NzParticleGeneratorListener = NzObjectListenerWrapper<NzParticleGenerator>;
using NzParticleGeneratorRef = NzObjectRef<NzParticleGenerator>; using NzParticleGeneratorRef = NzObjectRef<NzParticleGenerator>;
class NAZARA_API NzParticleGenerator : public NzRefCounted class NAZARA_API NzParticleGenerator : public NzRefCounted
@ -35,6 +33,9 @@ class NAZARA_API NzParticleGenerator : public NzRefCounted
virtual void Generate(NzParticleSystem& system, NzParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; virtual void Generate(NzParticleSystem& system, NzParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
// Signals:
NazaraSignal(OnParticleGeneratorRelease, const NzParticleGenerator*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -9,19 +9,17 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
class NzAbstractRenderQueue; class NzAbstractRenderQueue;
class NzParticleMapper; class NzParticleMapper;
class NzParticleRenderer; class NzParticleRenderer;
class NzParticleSystem; class NzParticleSystem;
using NzParticleRendererConstListener = NzObjectListenerWrapper<const NzParticleRenderer>;
using NzParticleRendererConstRef = NzObjectRef<const NzParticleRenderer>; using NzParticleRendererConstRef = NzObjectRef<const NzParticleRenderer>;
using NzParticleRendererLibrary = NzObjectLibrary<NzParticleRenderer>; using NzParticleRendererLibrary = NzObjectLibrary<NzParticleRenderer>;
using NzParticleRendererListener = NzObjectListenerWrapper<NzParticleRenderer>;
using NzParticleRendererRef = NzObjectRef<NzParticleRenderer>; using NzParticleRendererRef = NzObjectRef<NzParticleRenderer>;
class NAZARA_API NzParticleRenderer : public NzRefCounted class NAZARA_API NzParticleRenderer : public NzRefCounted
@ -36,6 +34,9 @@ class NAZARA_API NzParticleRenderer : public NzRefCounted
virtual void Render(const NzParticleSystem& system, const NzParticleMapper& mapper, unsigned int startId, unsigned int endId, NzAbstractRenderQueue* renderQueue) = 0; virtual void Render(const NzParticleSystem& system, const NzParticleMapper& mapper, unsigned int startId, unsigned int endId, NzAbstractRenderQueue* renderQueue) = 0;
// Signals:
NazaraSignal(OnParticleRendererRelease, const NzParticleRenderer*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -10,9 +10,9 @@
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/PrimitiveList.hpp> #include <Nazara/Core/PrimitiveList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Math/BoundingVolume.hpp> #include <Nazara/Math/BoundingVolume.hpp>
#include <Nazara/Math/Frustum.hpp> #include <Nazara/Math/Frustum.hpp>
#include <Nazara/Math/Matrix4.hpp> #include <Nazara/Math/Matrix4.hpp>
@ -20,10 +20,8 @@
class NzAbstractRenderQueue; class NzAbstractRenderQueue;
class NzRenderable; class NzRenderable;
using NzRenderableConstListener = NzObjectListenerWrapper<const NzRenderable>;
using NzRenderableConstRef = NzObjectRef<const NzRenderable>; using NzRenderableConstRef = NzObjectRef<const NzRenderable>;
using NzRenderableLibrary = NzObjectLibrary<NzRenderable>; using NzRenderableLibrary = NzObjectLibrary<NzRenderable>;
using NzRenderableListener = NzObjectListenerWrapper<NzRenderable>;
using NzRenderableRef = NzObjectRef<NzRenderable>; using NzRenderableRef = NzObjectRef<NzRenderable>;
class NAZARA_API NzRenderable : public NzRefCounted class NAZARA_API NzRenderable : public NzRefCounted
@ -42,6 +40,9 @@ class NAZARA_API NzRenderable : public NzRefCounted
inline NzRenderable& operator=(const NzRenderable& renderable); inline NzRenderable& operator=(const NzRenderable& renderable);
// Signals:
NazaraSignal(OnRenderableRelease, const NzRenderable*); //< Args: me
protected: protected:
virtual void MakeBoundingVolume() const = 0; virtual void MakeBoundingVolume() const = 0;
void InvalidateBoundingVolume(); void InvalidateBoundingVolume();

View File

@ -28,6 +28,9 @@ class NAZARA_API NzSkinningManager
private: private:
static bool Initialize(); static bool Initialize();
static void OnSkeletalMeshDestroy(const NzSkeletalMesh* mesh);
static void OnSkeletonInvalidated(const NzSkeleton* skeleton);
static void OnSkeletonRelease(const NzSkeleton* skeleton);
static void Uninitialize(); static void Uninitialize();
static SkinFunction s_skinFunc; static SkinFunction s_skinFunc;

View File

@ -11,9 +11,9 @@
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/PrimitiveList.hpp> #include <Nazara/Core/PrimitiveList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Math/Box.hpp> #include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Quaternion.hpp> #include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp> #include <Nazara/Math/Vector3.hpp>
@ -30,10 +30,8 @@ class NzPhysGeom;
class NzPhysWorld; class NzPhysWorld;
struct NewtonCollision; struct NewtonCollision;
using NzPhysGeomConstListener = NzObjectListenerWrapper<const NzPhysGeom>;
using NzPhysGeomConstRef = NzObjectRef<const NzPhysGeom>; using NzPhysGeomConstRef = NzObjectRef<const NzPhysGeom>;
using NzPhysGeomLibrary = NzObjectLibrary<NzPhysGeom>; using NzPhysGeomLibrary = NzObjectLibrary<NzPhysGeom>;
using NzPhysGeomListener = NzObjectListenerWrapper<NzPhysGeom>;
using NzPhysGeomRef = NzObjectRef<NzPhysGeom>; using NzPhysGeomRef = NzObjectRef<NzPhysGeom>;
class NAZARA_API NzPhysGeom : public NzRefCounted, NzNonCopyable class NAZARA_API NzPhysGeom : public NzRefCounted, NzNonCopyable
@ -52,6 +50,8 @@ class NAZARA_API NzPhysGeom : public NzRefCounted, NzNonCopyable
static NzPhysGeomRef Build(const NzPrimitiveList& list); static NzPhysGeomRef Build(const NzPrimitiveList& list);
NazaraSignal(OnPhysGeomRelease, const NzPhysGeom*); //< Args: me
protected: protected:
virtual NewtonCollision* CreateHandle(NzPhysWorld* world) const = 0; virtual NewtonCollision* CreateHandle(NzPhysWorld* world) const = 0;
@ -62,9 +62,7 @@ class NAZARA_API NzPhysGeom : public NzRefCounted, NzNonCopyable
class NzBoxGeom; class NzBoxGeom;
using NzBoxGeomConstListener = NzObjectListenerWrapper<const NzBoxGeom>;
using NzBoxGeomConstRef = NzObjectRef<const NzBoxGeom>; using NzBoxGeomConstRef = NzObjectRef<const NzBoxGeom>;
using NzBoxGeomListener = NzObjectListenerWrapper<NzBoxGeom>;
using NzBoxGeomRef = NzObjectRef<NzBoxGeom>; using NzBoxGeomRef = NzObjectRef<NzBoxGeom>;
class NAZARA_API NzBoxGeom : public NzPhysGeom class NAZARA_API NzBoxGeom : public NzPhysGeom
@ -90,9 +88,7 @@ class NAZARA_API NzBoxGeom : public NzPhysGeom
class NzCapsuleGeom; class NzCapsuleGeom;
using NzCapsuleGeomConstListener = NzObjectListenerWrapper<const NzCapsuleGeom>;
using NzCapsuleGeomConstRef = NzObjectRef<const NzCapsuleGeom>; using NzCapsuleGeomConstRef = NzObjectRef<const NzCapsuleGeom>;
using NzCapsuleGeomListener = NzObjectListenerWrapper<NzCapsuleGeom>;
using NzCapsuleGeomRef = NzObjectRef<NzCapsuleGeom>; using NzCapsuleGeomRef = NzObjectRef<NzCapsuleGeom>;
class NAZARA_API NzCapsuleGeom : public NzPhysGeom class NAZARA_API NzCapsuleGeom : public NzPhysGeom
@ -117,9 +113,7 @@ class NAZARA_API NzCapsuleGeom : public NzPhysGeom
class NzCompoundGeom; class NzCompoundGeom;
using NzCompoundGeomConstListener = NzObjectListenerWrapper<const NzCompoundGeom>;
using NzCompoundGeomConstRef = NzObjectRef<const NzCompoundGeom>; using NzCompoundGeomConstRef = NzObjectRef<const NzCompoundGeom>;
using NzCompoundGeomListener = NzObjectListenerWrapper<NzCompoundGeom>;
using NzCompoundGeomRef = NzObjectRef<NzCompoundGeom>; using NzCompoundGeomRef = NzObjectRef<NzCompoundGeom>;
class NAZARA_API NzCompoundGeom : public NzPhysGeom class NAZARA_API NzCompoundGeom : public NzPhysGeom
@ -140,9 +134,7 @@ class NAZARA_API NzCompoundGeom : public NzPhysGeom
class NzConeGeom; class NzConeGeom;
using NzConeGeomConstListener = NzObjectListenerWrapper<const NzConeGeom>;
using NzConeGeomConstRef = NzObjectRef<const NzConeGeom>; using NzConeGeomConstRef = NzObjectRef<const NzConeGeom>;
using NzConeGeomListener = NzObjectListenerWrapper<NzConeGeom>;
using NzConeGeomRef = NzObjectRef<NzConeGeom>; using NzConeGeomRef = NzObjectRef<NzConeGeom>;
class NAZARA_API NzConeGeom : public NzPhysGeom class NAZARA_API NzConeGeom : public NzPhysGeom
@ -167,9 +159,7 @@ class NAZARA_API NzConeGeom : public NzPhysGeom
class NzConvexHullGeom; class NzConvexHullGeom;
using NzConvexHullGeomConstListener = NzObjectListenerWrapper<const NzConvexHullGeom>;
using NzConvexHullGeomConstRef = NzObjectRef<const NzConvexHullGeom>; using NzConvexHullGeomConstRef = NzObjectRef<const NzConvexHullGeom>;
using NzConvexHullGeomListener = NzObjectListenerWrapper<NzConvexHullGeom>;
using NzConvexHullGeomRef = NzObjectRef<NzConvexHullGeom>; using NzConvexHullGeomRef = NzObjectRef<NzConvexHullGeom>;
class NAZARA_API NzConvexHullGeom : public NzPhysGeom class NAZARA_API NzConvexHullGeom : public NzPhysGeom
@ -193,9 +183,7 @@ class NAZARA_API NzConvexHullGeom : public NzPhysGeom
class NzCylinderGeom; class NzCylinderGeom;
using NzCylinderGeomConstListener = NzObjectListenerWrapper<const NzCylinderGeom>;
using NzCylinderGeomConstRef = NzObjectRef<const NzCylinderGeom>; using NzCylinderGeomConstRef = NzObjectRef<const NzCylinderGeom>;
using NzCylinderGeomListener = NzObjectListenerWrapper<NzCylinderGeom>;
using NzCylinderGeomRef = NzObjectRef<NzCylinderGeom>; using NzCylinderGeomRef = NzObjectRef<NzCylinderGeom>;
class NAZARA_API NzCylinderGeom : public NzPhysGeom class NAZARA_API NzCylinderGeom : public NzPhysGeom
@ -220,9 +208,7 @@ class NAZARA_API NzCylinderGeom : public NzPhysGeom
class NzNullGeom; class NzNullGeom;
using NzNullGeomConstListener = NzObjectListenerWrapper<const NzNullGeom>;
using NzNullGeomConstRef = NzObjectRef<const NzNullGeom>; using NzNullGeomConstRef = NzObjectRef<const NzNullGeom>;
using NzNullGeomListener = NzObjectListenerWrapper<NzNullGeom>;
using NzNullGeomRef = NzObjectRef<NzNullGeom>; using NzNullGeomRef = NzObjectRef<NzNullGeom>;
class NAZARA_API NzNullGeom : public NzPhysGeom class NAZARA_API NzNullGeom : public NzPhysGeom
@ -240,9 +226,7 @@ class NAZARA_API NzNullGeom : public NzPhysGeom
class NzSphereGeom; class NzSphereGeom;
using NzSphereGeomConstListener = NzObjectListenerWrapper<const NzSphereGeom>;
using NzSphereGeomConstRef = NzObjectRef<const NzSphereGeom>; using NzSphereGeomConstRef = NzObjectRef<const NzSphereGeom>;
using NzSphereGeomListener = NzObjectListenerWrapper<NzSphereGeom>;
using NzSphereGeomRef = NzObjectRef<NzSphereGeom>; using NzSphereGeomRef = NzObjectRef<NzSphereGeom>;
class NAZARA_API NzSphereGeom : public NzPhysGeom class NAZARA_API NzSphereGeom : public NzPhysGeom

View File

@ -9,7 +9,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp> #include <Nazara/Core/Signal.hpp>
@ -19,10 +18,8 @@
class NzContext; class NzContext;
using NzContextConstListener = NzObjectListenerWrapper<const NzContext>;
using NzContextConstRef = NzObjectRef<const NzContext>; using NzContextConstRef = NzObjectRef<const NzContext>;
using NzContextLibrary = NzObjectLibrary<NzContext>; using NzContextLibrary = NzObjectLibrary<NzContext>;
using NzContextListener = NzObjectListenerWrapper<NzContext>;
using NzContextRef = NzObjectRef<NzContext>; using NzContextRef = NzObjectRef<NzContext>;
class NzContextImpl; class NzContextImpl;
@ -51,7 +48,8 @@ class NAZARA_API NzContext : public NzRefCounted
static const NzContext* GetThreadContext(); static const NzContext* GetThreadContext();
// Signals // Signals
NazaraSignal(OnContextRelease, const NzContext*); //< me NazaraSignal(OnContextDestroy, const NzContext*); //< Args: me
NazaraSignal(OnContextRelease, const NzContext*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();

View File

@ -10,17 +10,15 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
class NzRenderBuffer; class NzRenderBuffer;
using NzRenderBufferConstListener = NzObjectListenerWrapper<const NzRenderBuffer>;
using NzRenderBufferConstRef = NzObjectRef<const NzRenderBuffer>; using NzRenderBufferConstRef = NzObjectRef<const NzRenderBuffer>;
using NzRenderBufferLibrary = NzObjectLibrary<NzRenderBuffer>; using NzRenderBufferLibrary = NzObjectLibrary<NzRenderBuffer>;
using NzRenderBufferListener = NzObjectListenerWrapper<NzRenderBuffer>;
using NzRenderBufferRef = NzObjectRef<NzRenderBuffer>; using NzRenderBufferRef = NzObjectRef<NzRenderBuffer>;
class NAZARA_API NzRenderBuffer : public NzRefCounted, NzNonCopyable class NAZARA_API NzRenderBuffer : public NzRefCounted, NzNonCopyable
@ -47,6 +45,10 @@ class NAZARA_API NzRenderBuffer : public NzRefCounted, NzNonCopyable
static bool IsSupported(); static bool IsSupported();
template<typename... Args> static NzRenderBufferRef New(Args&&... args); template<typename... Args> static NzRenderBufferRef New(Args&&... args);
// Signals
NazaraSignal(OnRenderBufferDestroy, const NzRenderBuffer*); //< Args: me
NazaraSignal(OnRenderBufferRelease, const NzRenderBuffer*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -9,18 +9,21 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectListener.hpp> #include <Nazara/Math/Rect.hpp>
#include <Nazara/Renderer/Config.hpp> #include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/RenderTarget.hpp> #include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Renderer/Texture.hpp> #include <Nazara/Utility/PixelFormat.hpp>
///TODO: Faire fonctionner les RenderTexture indépendamment du contexte (un FBO par instance et par contexte l'utilisant) ///TODO: Faire fonctionner les RenderTexture indépendamment du contexte (un FBO par instance et par contexte l'utilisant)
class NzContext;
class NzRenderBuffer; class NzRenderBuffer;
class NzTexture;
struct NzRenderTextureImpl; struct NzRenderTextureImpl;
class NAZARA_API NzRenderTexture : public NzRenderTarget, NzObjectListener, NzNonCopyable class NAZARA_API NzRenderTexture : public NzRenderTarget, NzNonCopyable
{ {
public: public:
NzRenderTexture() = default; NzRenderTexture() = default;
@ -66,7 +69,9 @@ class NAZARA_API NzRenderTexture : public NzRenderTarget, NzObjectListener, NzNo
void EnsureTargetUpdated() const override; void EnsureTargetUpdated() const override;
private: private:
bool OnObjectDestroy(const NzRefCounted* object, int index) override; void OnContextDestroy(const NzContext* context);
void OnRenderBufferDestroy(const NzRenderBuffer* renderBuffer, int attachmentIndex);
void OnTextureDestroy(const NzTexture* texture, int attachmentIndex);
void UpdateDrawBuffers() const; void UpdateDrawBuffers() const;
void UpdateSize() const; void UpdateSize() const;
void UpdateTargets() const; void UpdateTargets() const;

View File

@ -12,7 +12,6 @@
#include <Nazara/Core/Color.hpp> #include <Nazara/Core/Color.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp> #include <Nazara/Core/Signal.hpp>
@ -26,10 +25,8 @@
class NzShader; class NzShader;
class NzShaderStage; class NzShaderStage;
using NzShaderConstListener = NzObjectListenerWrapper<const NzShader>;
using NzShaderConstRef = NzObjectRef<const NzShader>; using NzShaderConstRef = NzObjectRef<const NzShader>;
using NzShaderLibrary = NzObjectLibrary<NzShader>; using NzShaderLibrary = NzObjectLibrary<NzShader>;
using NzShaderListener = NzObjectListenerWrapper<NzShader>;
using NzShaderRef = NzObjectRef<NzShader>; using NzShaderRef = NzObjectRef<NzShader>;
class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable
@ -104,6 +101,7 @@ class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable
template<typename... Args> static NzShaderRef New(Args&&... args); template<typename... Args> static NzShaderRef New(Args&&... args);
// Signals // Signals
NazaraSignal(OnShaderDestroy, const NzShader*); //< Args: me
NazaraSignal(OnShaderRelease, const NzShader*); //< Args: me NazaraSignal(OnShaderRelease, const NzShader*); //< Args: me
NazaraSignal(OnShaderUniformInvalidated, const NzShader*); //< Args: me NazaraSignal(OnShaderUniformInvalidated, const NzShader*); //< Args: me

View File

@ -10,7 +10,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp> #include <Nazara/Core/Resource.hpp>
@ -23,10 +22,8 @@
class NzTexture; class NzTexture;
using NzTextureConstListener = NzObjectListenerWrapper<const NzTexture>;
using NzTextureConstRef = NzObjectRef<const NzTexture>; using NzTextureConstRef = NzObjectRef<const NzTexture>;
using NzTextureLibrary = NzObjectLibrary<NzTexture>; using NzTextureLibrary = NzObjectLibrary<NzTexture>;
using NzTextureListener = NzObjectListenerWrapper<NzTexture>;
using NzTextureManager = NzResourceManager<NzTexture, NzImageParams>; using NzTextureManager = NzResourceManager<NzTexture, NzImageParams>;
using NzTextureRef = NzObjectRef<NzTexture>; using NzTextureRef = NzObjectRef<NzTexture>;
@ -111,6 +108,7 @@ class NAZARA_API NzTexture : public NzAbstractImage, public NzRefCounted, public
template<typename... Args> static NzTextureRef New(Args&&... args); template<typename... Args> static NzTextureRef New(Args&&... args);
// Signals // Signals
NazaraSignal(OnTextureDestroy, const NzTexture*); //< Args: me
NazaraSignal(OnTextureRelease, const NzTexture*); //< Args: me NazaraSignal(OnTextureRelease, const NzTexture*); //< Args: me
private: private:

View File

@ -10,7 +10,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ParameterList.hpp> #include <Nazara/Core/ParameterList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Renderer/UberShaderInstance.hpp> #include <Nazara/Renderer/UberShaderInstance.hpp>
@ -18,10 +17,8 @@
class NzUberShader; class NzUberShader;
using NzUberShaderConstListener = NzObjectListenerWrapper<const NzUberShader>;
using NzUberShaderConstRef = NzObjectRef<const NzUberShader>; using NzUberShaderConstRef = NzObjectRef<const NzUberShader>;
using NzUberShaderLibrary = NzObjectLibrary<NzUberShader>; using NzUberShaderLibrary = NzObjectLibrary<NzUberShader>;
using NzUberShaderListener = NzObjectListenerWrapper<NzUberShader>;
using NzUberShaderRef = NzObjectRef<NzUberShader>; using NzUberShaderRef = NzObjectRef<NzUberShader>;
class NAZARA_API NzUberShader : public NzRefCounted class NAZARA_API NzUberShader : public NzRefCounted
@ -35,6 +32,8 @@ class NAZARA_API NzUberShader : public NzRefCounted
virtual NzUberShaderInstance* Get(const NzParameterList& parameters) const = 0; virtual NzUberShaderInstance* Get(const NzParameterList& parameters) const = 0;
NazaraSignal(OnUberShaderRelease, const NzUberShader*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -9,7 +9,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Enums.hpp> #include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Renderer/Shader.hpp> #include <Nazara/Renderer/Shader.hpp>
#include <Nazara/Renderer/ShaderStage.hpp> #include <Nazara/Renderer/ShaderStage.hpp>
@ -19,16 +18,14 @@
class NzUberShaderPreprocessor; class NzUberShaderPreprocessor;
using NzUberShaderPreprocessorConstListener = NzObjectListenerWrapper<const NzUberShaderPreprocessor>;
using NzUberShaderPreprocessorConstRef = NzObjectRef<const NzUberShaderPreprocessor>; using NzUberShaderPreprocessorConstRef = NzObjectRef<const NzUberShaderPreprocessor>;
using NzUberShaderPreprocessorListener = NzObjectListenerWrapper<NzUberShaderPreprocessor>;
using NzUberShaderPreprocessorRef = NzObjectRef<NzUberShaderPreprocessor>; using NzUberShaderPreprocessorRef = NzObjectRef<NzUberShaderPreprocessor>;
class NAZARA_API NzUberShaderPreprocessor : public NzUberShader class NAZARA_API NzUberShaderPreprocessor : public NzUberShader
{ {
public: public:
NzUberShaderPreprocessor() = default; NzUberShaderPreprocessor() = default;
~NzUberShaderPreprocessor() = default; ~NzUberShaderPreprocessor();
NzUberShaderInstance* Get(const NzParameterList& parameters) const; NzUberShaderInstance* Get(const NzParameterList& parameters) const;
@ -38,6 +35,9 @@ class NAZARA_API NzUberShaderPreprocessor : public NzUberShader
static bool IsSupported(); static bool IsSupported();
template<typename... Args> static NzUberShaderPreprocessorRef New(Args&&... args); template<typename... Args> static NzUberShaderPreprocessorRef New(Args&&... args);
// Signals:
NazaraSignal(OnUberShaderPreprocessorRelease, const NzUberShaderPreprocessor*); //< Args: me
private: private:
struct Shader struct Shader
{ {

View File

@ -9,12 +9,12 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp> #include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp> #include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceManager.hpp> #include <Nazara/Core/ResourceManager.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/Sequence.hpp> #include <Nazara/Utility/Sequence.hpp>
@ -33,10 +33,8 @@ struct NAZARA_API NzAnimationParams
class NzAnimation; class NzAnimation;
class NzSkeleton; class NzSkeleton;
using NzAnimationConstListener = NzObjectListenerWrapper<const NzAnimation>;
using NzAnimationConstRef = NzObjectRef<const NzAnimation>; using NzAnimationConstRef = NzObjectRef<const NzAnimation>;
using NzAnimationLibrary = NzObjectLibrary<NzAnimation>; using NzAnimationLibrary = NzObjectLibrary<NzAnimation>;
using NzAnimationListener = NzObjectListenerWrapper<NzAnimation>;
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>; using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
using NzAnimationManager = NzResourceManager<NzAnimation, NzAnimationParams>; using NzAnimationManager = NzResourceManager<NzAnimation, NzAnimationParams>;
using NzAnimationRef = NzObjectRef<NzAnimation>; using NzAnimationRef = NzObjectRef<NzAnimation>;
@ -89,6 +87,10 @@ class NAZARA_API NzAnimation : public NzRefCounted, public NzResource
template<typename... Args> static NzAnimationRef New(Args&&... args); template<typename... Args> static NzAnimationRef New(Args&&... args);
// Signals
NazaraSignal(OnAnimationDestroy, const NzAnimation*); //< Args: me
NazaraSignal(OnAnimationRelease, const NzAnimation*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -9,16 +9,14 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
class NzBuffer; class NzBuffer;
using NzBufferConstListener = NzObjectListenerWrapper<const NzBuffer>;
using NzBufferConstRef = NzObjectRef<const NzBuffer>; using NzBufferConstRef = NzObjectRef<const NzBuffer>;
using NzBufferListener = NzObjectListenerWrapper<NzBuffer>;
using NzBufferRef = NzObjectRef<NzBuffer>; using NzBufferRef = NzObjectRef<NzBuffer>;
class NzAbstractBuffer; class NzAbstractBuffer;
@ -61,6 +59,10 @@ class NAZARA_API NzBuffer : public NzRefCounted, NzNonCopyable
template<typename... Args> static NzBufferRef New(Args&&... args); template<typename... Args> static NzBufferRef New(Args&&... args);
static void SetBufferFactory(nzUInt32 storage, BufferFactory func); static void SetBufferFactory(nzUInt32 storage, BufferFactory func);
// Signals:
NazaraSignal(OnBufferDestroy, const NzBuffer*); //< Args: me
NazaraSignal(OnBufferRelease, const NzBuffer*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();

View File

@ -12,7 +12,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp> #include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Resource.hpp> #include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp> #include <Nazara/Core/ResourceLoader.hpp>
@ -30,10 +29,8 @@ class NzFontData;
struct NzFontGlyph; struct NzFontGlyph;
using NzFontConstListener = NzObjectListenerWrapper<const NzFont>;
using NzFontConstRef = NzObjectRef<const NzFont>; using NzFontConstRef = NzObjectRef<const NzFont>;
using NzFontLibrary = NzObjectLibrary<NzFont>; using NzFontLibrary = NzObjectLibrary<NzFont>;
using NzFontListener = NzObjectListenerWrapper<NzFont>;
using NzFontLoader = NzResourceLoader<NzFont, NzFontParams>; using NzFontLoader = NzResourceLoader<NzFont, NzFontParams>;
using NzFontRef = NzObjectRef<NzFont>; using NzFontRef = NzObjectRef<NzFont>;
@ -117,6 +114,7 @@ class NAZARA_API NzFont : public NzRefCounted, public NzResource, NzNonCopyable
NazaraSignal(OnFontAtlasChanged, const NzFont*); //< Args: me NazaraSignal(OnFontAtlasChanged, const NzFont*); //< Args: me
NazaraSignal(OnFontAtlasLayerChanged, const NzFont*); //< Args: me NazaraSignal(OnFontAtlasLayerChanged, const NzFont*); //< Args: me
NazaraSignal(OnFontDestroy, const NzFont*); //< Args: me
NazaraSignal(OnFontGlyphCacheCleared, const NzFont*); //< Args: me NazaraSignal(OnFontGlyphCacheCleared, const NzFont*); //< Args: me
NazaraSignal(OnFontKerningCacheCleared, const NzFont*); //< Args: me NazaraSignal(OnFontKerningCacheCleared, const NzFont*); //< Args: me
NazaraSignal(OnFontRelease, const NzFont*); //< Args: me NazaraSignal(OnFontRelease, const NzFont*); //< Args: me

View File

@ -11,12 +11,12 @@
#include <Nazara/Core/Color.hpp> #include <Nazara/Core/Color.hpp>
#include <Nazara/Core/InputStream.hpp> #include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp> #include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp> #include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceManager.hpp> #include <Nazara/Core/ResourceManager.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/AbstractImage.hpp> #include <Nazara/Utility/AbstractImage.hpp>
#include <Nazara/Utility/CubemapParams.hpp> #include <Nazara/Utility/CubemapParams.hpp>
#include <atomic> #include <atomic>
@ -36,10 +36,8 @@ struct NAZARA_API NzImageParams
class NzImage; class NzImage;
using NzImageConstListener = NzObjectListenerWrapper<const NzImage>;
using NzImageConstRef = NzObjectRef<const NzImage>; using NzImageConstRef = NzObjectRef<const NzImage>;
using NzImageLibrary = NzObjectLibrary<NzImage>; using NzImageLibrary = NzObjectLibrary<NzImage>;
using NzImageListener = NzObjectListenerWrapper<NzImage>;
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>; using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
using NzImageManager = NzResourceManager<NzImage, NzImageParams>; using NzImageManager = NzResourceManager<NzImage, NzImageParams>;
using NzImageRef = NzObjectRef<NzImage>; using NzImageRef = NzObjectRef<NzImage>;
@ -148,6 +146,10 @@ class NAZARA_API NzImage : public NzAbstractImage, public NzRefCounted, public N
static SharedImage emptyImage; static SharedImage emptyImage;
// Signals:
NazaraSignal(OnImageDestroy, const NzImage*); //< Args: me
NazaraSignal(OnImageRelease, const NzImage*); //< Args: me
private: private:
void EnsureOwnership(); void EnsureOwnership();
void ReleaseImage(); void ReleaseImage();

View File

@ -8,16 +8,13 @@
#define NAZARA_INDEXBUFFER_HPP #define NAZARA_INDEXBUFFER_HPP
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Signal.hpp> #include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/Buffer.hpp> #include <Nazara/Utility/Buffer.hpp>
class NzIndexBuffer; class NzIndexBuffer;
using NzIndexBufferConstListener = NzObjectListenerWrapper<const NzIndexBuffer>;
using NzIndexBufferConstRef = NzObjectRef<const NzIndexBuffer>; using NzIndexBufferConstRef = NzObjectRef<const NzIndexBuffer>;
using NzIndexBufferListener = NzObjectListenerWrapper<NzIndexBuffer>;
using NzIndexBufferRef = NzObjectRef<NzIndexBuffer>; using NzIndexBufferRef = NzObjectRef<NzIndexBuffer>;
class NAZARA_API NzIndexBuffer : public NzRefCounted class NAZARA_API NzIndexBuffer : public NzRefCounted
@ -68,7 +65,7 @@ class NAZARA_API NzIndexBuffer : public NzRefCounted
template<typename... Args> static NzIndexBufferRef New(Args&&... args); template<typename... Args> static NzIndexBufferRef New(Args&&... args);
// Signals // Signals
NazaraSignal(OnIndexBufferRelease, const NzIndexBuffer*); //< me NazaraSignal(OnIndexBufferRelease, const NzIndexBuffer*); //< Args: me
private: private:
NzBufferRef m_buffer; NzBufferRef m_buffer;

View File

@ -10,7 +10,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/InputStream.hpp> #include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Primitive.hpp> #include <Nazara/Core/Primitive.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
@ -54,10 +53,8 @@ class NzPrimitiveList;
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex; typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex; typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex;
using NzMeshConstListener = NzObjectListenerWrapper<const NzMesh>;
using NzMeshConstRef = NzObjectRef<const NzMesh>; using NzMeshConstRef = NzObjectRef<const NzMesh>;
using NzMeshLibrary = NzObjectLibrary<NzMesh>; using NzMeshLibrary = NzObjectLibrary<NzMesh>;
using NzMeshListener = NzObjectListenerWrapper<NzMesh>;
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>; using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
using NzMeshManager = NzResourceManager<NzMesh, NzMeshParams>; using NzMeshManager = NzResourceManager<NzMesh, NzMeshParams>;
using NzMeshRef = NzObjectRef<NzMesh>; using NzMeshRef = NzObjectRef<NzMesh>;
@ -131,6 +128,10 @@ class NAZARA_API NzMesh : public NzRefCounted, public NzResource
template<typename... Args> static NzMeshRef New(Args&&... args); template<typename... Args> static NzMeshRef New(Args&&... args);
// Signals:
NazaraSignal(OnMeshDestroy, const NzMesh*); //< Args: me
NazaraSignal(OnMeshRelease, const NzMesh*); //< Args: me
private: private:
NzMeshImpl* m_impl = nullptr; NzMeshImpl* m_impl = nullptr;

View File

@ -8,7 +8,6 @@
#define NAZARA_SIMPLETEXTDRAWER_HPP #define NAZARA_SIMPLETEXTDRAWER_HPP
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/Utility/AbstractTextDrawer.hpp> #include <Nazara/Utility/AbstractTextDrawer.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
@ -21,7 +20,7 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer
NzSimpleTextDrawer(); NzSimpleTextDrawer();
NzSimpleTextDrawer(const NzSimpleTextDrawer& drawer); NzSimpleTextDrawer(const NzSimpleTextDrawer& drawer);
NzSimpleTextDrawer(NzSimpleTextDrawer&&) = default; NzSimpleTextDrawer(NzSimpleTextDrawer&&) = default;
virtual ~NzSimpleTextDrawer() = default; virtual ~NzSimpleTextDrawer();
const NzRectui& GetBounds() const; const NzRectui& GetBounds() const;
unsigned int GetCharacterSize() const; unsigned int GetCharacterSize() const;

View File

@ -8,15 +8,13 @@
#define NAZARA_SKELETALMESH_HPP #define NAZARA_SKELETALMESH_HPP
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/SubMesh.hpp> #include <Nazara/Utility/SubMesh.hpp>
class NzSkeletalMesh; class NzSkeletalMesh;
using NzSkeletalMeshConstListener = NzObjectListenerWrapper<const NzSkeletalMesh>;
using NzSkeletalMeshConstRef = NzObjectRef<const NzSkeletalMesh>; using NzSkeletalMeshConstRef = NzObjectRef<const NzSkeletalMesh>;
using NzSkeletalMeshListener = NzObjectListenerWrapper<NzSkeletalMesh>;
using NzSkeletalMeshRef = NzObjectRef<NzSkeletalMesh>; using NzSkeletalMeshRef = NzObjectRef<NzSkeletalMesh>;
class NAZARA_API NzSkeletalMesh final : public NzSubMesh class NAZARA_API NzSkeletalMesh final : public NzSubMesh
@ -43,6 +41,10 @@ class NAZARA_API NzSkeletalMesh final : public NzSubMesh
template<typename... Args> static NzSkeletalMeshRef New(Args&&... args); template<typename... Args> static NzSkeletalMeshRef New(Args&&... args);
// Signals:
NazaraSignal(OnSkeletalMeshDestroy, const NzSkeletalMesh*); //< Args: me
NazaraSignal(OnSkeletalMeshRelease, const NzSkeletalMesh*); //< Args: me
private: private:
NzBoxf m_aabb; NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr; NzIndexBufferConstRef m_indexBuffer = nullptr;

View File

@ -9,19 +9,17 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Math/Box.hpp> #include <Nazara/Math/Box.hpp>
#include <Nazara/Utility/Joint.hpp> #include <Nazara/Utility/Joint.hpp>
#include <vector> #include <vector>
class NzSkeleton; class NzSkeleton;
using NzSkeletonConstListener = NzObjectListenerWrapper<const NzSkeleton>;
using NzSkeletonConstRef = NzObjectRef<const NzSkeleton>; using NzSkeletonConstRef = NzObjectRef<const NzSkeleton>;
using NzSkeletonLibrary = NzObjectLibrary<NzSkeleton>; using NzSkeletonLibrary = NzObjectLibrary<NzSkeleton>;
using NzSkeletonListener = NzObjectListenerWrapper<NzSkeleton>;
using NzSkeletonRef = NzObjectRef<NzSkeleton>; using NzSkeletonRef = NzObjectRef<NzSkeleton>;
struct NzSkeletonImpl; struct NzSkeletonImpl;
@ -59,6 +57,11 @@ class NAZARA_API NzSkeleton : public NzRefCounted
template<typename... Args> static NzSkeletonRef New(Args&&... args); template<typename... Args> static NzSkeletonRef New(Args&&... args);
// Signals:
NazaraSignal(OnSkeletonDestroy, const NzSkeleton*); //< Args: me
NazaraSignal(OnSkeletonJointsInvalidated, const NzSkeleton*); //< Args: me
NazaraSignal(OnSkeletonRelease, const NzSkeleton*); //< Args: me
private: private:
void InvalidateJoints(); void InvalidateJoints();
void InvalidateJointMap(); void InvalidateJointMap();

View File

@ -8,15 +8,12 @@
#define NAZARA_STATICMESH_HPP #define NAZARA_STATICMESH_HPP
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListener.hpp> #include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Utility/SubMesh.hpp> #include <Nazara/Utility/SubMesh.hpp>
class NzStaticMesh; class NzStaticMesh;
using NzStaticMeshConstListener = NzObjectListenerWrapper<const NzStaticMesh>;
using NzStaticMeshConstRef = NzObjectRef<const NzStaticMesh>; using NzStaticMeshConstRef = NzObjectRef<const NzStaticMesh>;
using NzStaticMeshListener = NzObjectListenerWrapper<NzStaticMesh>;
using NzStaticMeshRef = NzObjectRef<NzStaticMesh>; using NzStaticMeshRef = NzObjectRef<NzStaticMesh>;
class NAZARA_API NzStaticMesh final : public NzSubMesh class NAZARA_API NzStaticMesh final : public NzSubMesh
@ -47,6 +44,10 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh
template<typename... Args> static NzStaticMeshRef New(Args&&... args); template<typename... Args> static NzStaticMeshRef New(Args&&... args);
// Signals:
NazaraSignal(OnStaticMeshDestroy, const NzStaticMesh*); //< Args: me
NazaraSignal(OnStaticMeshRelease, const NzStaticMesh*); //< Args: me
private: private:
NzBoxf m_aabb; NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr; NzIndexBufferConstRef m_indexBuffer = nullptr;

View File

@ -8,7 +8,6 @@
#define NAZARA_SUBMESH_HPP #define NAZARA_SUBMESH_HPP
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Math/Box.hpp> #include <Nazara/Math/Box.hpp>
@ -20,9 +19,7 @@
class NzMesh; class NzMesh;
class NzSubMesh; class NzSubMesh;
using NzSubMeshConstListener = NzObjectListenerWrapper<const NzSubMesh>;
using NzSubMeshConstRef = NzObjectRef<const NzSubMesh>; using NzSubMeshConstRef = NzObjectRef<const NzSubMesh>;
using NzSubMeshListener = NzObjectListenerWrapper<NzSubMesh>;
using NzSubMeshRef = NzObjectRef<NzSubMesh>; using NzSubMeshRef = NzObjectRef<NzSubMesh>;
class NAZARA_API NzSubMesh : public NzRefCounted class NAZARA_API NzSubMesh : public NzRefCounted
@ -51,6 +48,9 @@ class NAZARA_API NzSubMesh : public NzRefCounted
void SetMaterialIndex(unsigned int matIndex); void SetMaterialIndex(unsigned int matIndex);
void SetPrimitiveMode(nzPrimitiveMode mode); void SetPrimitiveMode(nzPrimitiveMode mode);
// Signals:
NazaraSignal(OnSubMeshRelease, const NzSubMesh*); //< Args: me
protected: protected:
nzPrimitiveMode m_primitiveMode; nzPrimitiveMode m_primitiveMode;
const NzMesh* m_parent; const NzMesh* m_parent;

View File

@ -8,7 +8,6 @@
#define NAZARA_VERTEXBUFFER_HPP #define NAZARA_VERTEXBUFFER_HPP
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp> #include <Nazara/Core/Signal.hpp>
@ -17,9 +16,7 @@
class NzVertexBuffer; class NzVertexBuffer;
using NzVertexBufferConstListener = NzObjectListenerWrapper<const NzVertexBuffer>;
using NzVertexBufferConstRef = NzObjectRef<NzVertexBuffer>; using NzVertexBufferConstRef = NzObjectRef<NzVertexBuffer>;
using NzVertexBufferListener = NzObjectListenerWrapper<NzVertexBuffer>;
using NzVertexBufferRef = NzObjectRef<NzVertexBuffer>; using NzVertexBufferRef = NzObjectRef<NzVertexBuffer>;
class NAZARA_API NzVertexBuffer : public NzRefCounted class NAZARA_API NzVertexBuffer : public NzRefCounted
@ -66,7 +63,7 @@ class NAZARA_API NzVertexBuffer : public NzRefCounted
template<typename... Args> static NzVertexBufferRef New(Args&&... args); template<typename... Args> static NzVertexBufferRef New(Args&&... args);
// Signals // Signals
NazaraSignal(OnVertexBufferRelease, const NzVertexBuffer*); //< me NazaraSignal(OnVertexBufferRelease, const NzVertexBuffer*); //< Args: me
private: private:
NzBufferRef m_buffer; NzBufferRef m_buffer;

View File

@ -9,7 +9,6 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp> #include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp> #include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp> #include <Nazara/Core/Signal.hpp>
@ -17,10 +16,8 @@
class NzVertexDeclaration; class NzVertexDeclaration;
using NzVertexDeclarationConstListener = NzObjectListenerWrapper<const NzVertexDeclaration>;
using NzVertexDeclarationConstRef = NzObjectRef<const NzVertexDeclaration>; using NzVertexDeclarationConstRef = NzObjectRef<const NzVertexDeclaration>;
using NzVertexDeclarationLibrary = NzObjectLibrary<NzVertexDeclaration>; using NzVertexDeclarationLibrary = NzObjectLibrary<NzVertexDeclaration>;
using NzVertexDeclarationListener = NzObjectListenerWrapper<NzVertexDeclaration>;
using NzVertexDeclarationRef = NzObjectRef<NzVertexDeclaration>; using NzVertexDeclarationRef = NzObjectRef<NzVertexDeclaration>;
class NAZARA_API NzVertexDeclaration : public NzRefCounted class NAZARA_API NzVertexDeclaration : public NzRefCounted
@ -48,7 +45,7 @@ class NAZARA_API NzVertexDeclaration : public NzRefCounted
template<typename... Args> static NzVertexDeclarationRef New(Args&&... args); template<typename... Args> static NzVertexDeclarationRef New(Args&&... args);
// Signals // Signals
NazaraSignal(OnVertexDeclarationRelease, const NzVertexDeclaration*); //< me NazaraSignal(OnVertexDeclarationRelease, const NzVertexDeclaration*); //< Args: me
private: private:
static bool Initialize(); static bool Initialize();

View File

@ -44,6 +44,8 @@ NzSoundBuffer::NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, uns
NzSoundBuffer::~NzSoundBuffer() NzSoundBuffer::~NzSoundBuffer()
{ {
OnSoundBufferRelease(this);
Destroy(); Destroy();
} }
@ -108,7 +110,6 @@ bool NzSoundBuffer::Create(nzAudioFormat format, unsigned int sampleCount, unsig
m_impl->samples.reset(new nzInt16[sampleCount]); m_impl->samples.reset(new nzInt16[sampleCount]);
std::memcpy(&m_impl->samples[0], samples, sampleCount*sizeof(nzInt16)); std::memcpy(&m_impl->samples[0], samples, sampleCount*sizeof(nzInt16));
NotifyCreated();
return true; return true;
} }
@ -116,7 +117,7 @@ void NzSoundBuffer::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); OnSoundBufferDestroy(this);
delete m_impl; delete m_impl;
m_impl = nullptr; m_impl = nullptr;

View File

@ -1,39 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/Debug.hpp>
NzObjectListener::~NzObjectListener() = default;
bool NzObjectListener::OnObjectCreated(const NzRefCounted* object, int index)
{
NazaraUnused(object);
NazaraUnused(index);
return true;
}
bool NzObjectListener::OnObjectDestroy(const NzRefCounted* object, int index)
{
NazaraUnused(object);
NazaraUnused(index);
return true;
}
bool NzObjectListener::OnObjectModified(const NzRefCounted* object, int index, unsigned int code)
{
NazaraUnused(object);
NazaraUnused(index);
NazaraUnused(code);
return true;
}
void NzObjectListener::OnObjectReleased(const NzRefCounted* object, int index)
{
NazaraUnused(object);
NazaraUnused(index);
}

View File

@ -5,7 +5,6 @@
#include <Nazara/Core/RefCounted.hpp> #include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Config.hpp> #include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED #if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED
#include <Nazara/Core/ThreadSafety.hpp> #include <Nazara/Core/ThreadSafety.hpp>
@ -17,36 +16,18 @@
NzRefCounted::NzRefCounted(bool persistent) : NzRefCounted::NzRefCounted(bool persistent) :
m_persistent(persistent), m_persistent(persistent),
m_referenceCount(0), m_referenceCount(0)
m_objectListenersLocked(false)
{ {
} }
NzRefCounted::~NzRefCounted() NzRefCounted::~NzRefCounted()
{ {
m_objectListenersLocked = true;
for (auto& pair : m_objectListeners)
pair.first->OnObjectReleased(this, pair.second.first);
#if NAZARA_CORE_SAFE #if NAZARA_CORE_SAFE
if (m_referenceCount > 0) if (m_referenceCount > 0)
NazaraWarning("Resource destroyed while still referenced " + NzString::Number(m_referenceCount) + " time(s)"); NazaraWarning("Resource destroyed while still referenced " + NzString::Number(m_referenceCount) + " time(s)");
#endif #endif
} }
void NzRefCounted::AddObjectListener(NzObjectListener* listener, int index) const
{
///DOC: Est ignoré si appelé depuis un évènement
NazaraLock(m_mutex)
if (!m_objectListenersLocked)
{
auto pair = m_objectListeners.insert(std::make_pair(listener, std::make_pair(index, 1U)));
if (!pair.second)
pair.first->second.second++;
}
}
void NzRefCounted::AddReference() const void NzRefCounted::AddReference() const
{ {
m_referenceCount++; m_referenceCount++;
@ -62,23 +43,6 @@ bool NzRefCounted::IsPersistent() const
return m_persistent; return m_persistent;
} }
void NzRefCounted::RemoveObjectListener(NzObjectListener* listener) const
{
///DOC: Est ignoré si appelé depuis un évènement
NazaraLock(m_mutex);
if (!m_objectListenersLocked)
{
ObjectListenerMap::iterator it = m_objectListeners.find(listener);
if (it != m_objectListeners.end())
{
unsigned int& referenceCount = it->second.second;
if (--referenceCount == 0)
m_objectListeners.erase(it);
}
}
}
bool NzRefCounted::RemoveReference() const bool NzRefCounted::RemoveReference() const
{ {
#if NAZARA_CORE_SAFE #if NAZARA_CORE_SAFE
@ -113,56 +77,3 @@ bool NzRefCounted::SetPersistent(bool persistent, bool checkReferenceCount)
return false; return false;
} }
void NzRefCounted::NotifyCreated()
{
NazaraLock(m_mutex)
m_objectListenersLocked = true;
auto it = m_objectListeners.begin();
while (it != m_objectListeners.end())
{
if (!it->first->OnObjectCreated(this, it->second.first))
m_objectListeners.erase(it++);
else
++it;
}
m_objectListenersLocked = false;
}
void NzRefCounted::NotifyDestroy()
{
NazaraLock(m_mutex)
m_objectListenersLocked = true;
auto it = m_objectListeners.begin();
while (it != m_objectListeners.end())
{
if (!it->first->OnObjectDestroy(this, it->second.first))
m_objectListeners.erase(it++);
else
++it;
}
m_objectListenersLocked = false;
}
void NzRefCounted::NotifyModified(unsigned int code)
{
NazaraLock(m_mutex)
m_objectListenersLocked = true;
auto it = m_objectListeners.begin();
while (it != m_objectListeners.end())
{
if (!it->first->OnObjectModified(this, it->second.first, code))
m_objectListeners.erase(it++);
else
++it;
}
m_objectListenersLocked = false;
}

View File

@ -375,7 +375,7 @@ bool NzMaterial::LoadFromStream(NzInputStream& stream, const NzMaterialParams& p
void NzMaterial::Reset() void NzMaterial::Reset()
{ {
NotifyDestroy(); OnMaterialReset(this);
m_alphaMap.Reset(); m_alphaMap.Reset();
m_diffuseMap.Reset(); m_diffuseMap.Reset();

View File

@ -11,7 +11,10 @@ NzRefCounted()
NazaraUnused(controller); NazaraUnused(controller);
} }
NzParticleController::~NzParticleController() = default; NzParticleController::~NzParticleController()
{
OnParticleControllerRelease(this);
}
bool NzParticleController::Initialize() bool NzParticleController::Initialize()
{ {

View File

@ -27,7 +27,7 @@ m_stride(declaration.m_stride)
NzParticleDeclaration::~NzParticleDeclaration() NzParticleDeclaration::~NzParticleDeclaration()
{ {
NotifyDestroy(); OnParticleDeclarationRelease(this);
} }
void NzParticleDeclaration::DisableComponent(nzParticleComponent component) void NzParticleDeclaration::DisableComponent(nzParticleComponent component)

View File

@ -11,7 +11,10 @@ NzRefCounted()
NazaraUnused(generator); NazaraUnused(generator);
} }
NzParticleGenerator::~NzParticleGenerator() = default; NzParticleGenerator::~NzParticleGenerator()
{
OnParticleGeneratorRelease(this);
}
bool NzParticleGenerator::Initialize() bool NzParticleGenerator::Initialize()
{ {

View File

@ -11,7 +11,10 @@ NzRefCounted()
NazaraUnused(renderer); NazaraUnused(renderer);
} }
NzParticleRenderer::~NzParticleRenderer() = default; NzParticleRenderer::~NzParticleRenderer()
{
OnParticleRendererRelease(this);
}
bool NzParticleRenderer::Initialize() bool NzParticleRenderer::Initialize()
{ {

View File

@ -5,7 +5,10 @@
#include <Nazara/Graphics/Renderable.hpp> #include <Nazara/Graphics/Renderable.hpp>
#include <Nazara/Graphics/Debug.hpp> #include <Nazara/Graphics/Debug.hpp>
NzRenderable::~NzRenderable() = default; NzRenderable::~NzRenderable()
{
OnRenderableRelease(this);
}
bool NzRenderable::Cull(const NzFrustumf& frustum, const NzBoundingVolumef& volume, const NzMatrix4f& transformMatrix) const bool NzRenderable::Cull(const NzFrustumf& frustum, const NzBoundingVolumef& volume, const NzMatrix4f& transformMatrix) const
{ {

View File

@ -4,7 +4,6 @@
#include <Nazara/Graphics/SkinningManager.hpp> #include <Nazara/Graphics/SkinningManager.hpp>
#include <Nazara/Core/ErrorFlags.hpp> #include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/TaskScheduler.hpp> #include <Nazara/Core/TaskScheduler.hpp>
#include <Nazara/Utility/Algorithm.hpp> #include <Nazara/Utility/Algorithm.hpp>
#include <Nazara/Utility/SkeletalMesh.hpp> #include <Nazara/Utility/SkeletalMesh.hpp>
@ -16,92 +15,35 @@
namespace namespace
{ {
enum ObjectType
{
ObjectType_SkeletalMesh,
ObjectType_Skeleton,
};
struct BufferData struct BufferData
{ {
NazaraSlot(NzSkeletalMesh, OnSkeletalMeshDestroy, skeletalMeshDestroySlot);
NzVertexBufferRef buffer; NzVertexBufferRef buffer;
bool updated; bool updated;
}; };
struct SkinningData using MeshMap = std::unordered_map<const NzSkeletalMesh*, BufferData>;
{
const NzSkeletalMesh* mesh;
const NzSkeleton* skeleton;
NzVertexBuffer* buffer;
};
using MeshMap = std::unordered_map<const NzSkeletalMesh*, std::pair<NzSkeletalMeshConstListener, BufferData>>; struct MeshData
using SkeletonMap = std::unordered_map<const NzSkeleton*, std::pair<NzSkeletonConstListener, MeshMap>>; {
NazaraSlot(NzSkeleton, OnSkeletonDestroy, skeletonDestroySlot);
NazaraSlot(NzSkeleton, OnSkeletonJointsInvalidated, skeletonJointsInvalidatedSlot);
MeshMap meshMap;
};
struct SkinningData
{
const NzSkeletalMesh* mesh;
const NzSkeleton* skeleton;
NzVertexBuffer* buffer;
};
using SkeletonMap = std::unordered_map<const NzSkeleton*, MeshData>;
SkeletonMap s_cache; SkeletonMap s_cache;
std::vector<SkinningData> s_skinningQueue; std::vector<SkinningData> s_skinningQueue;
class ObjectListener : public NzObjectListener
{
public:
bool OnObjectDestroy(const NzRefCounted* object, int index) override
{
switch (index)
{
case ObjectType_SkeletalMesh:
{
for (auto& pair : s_cache)
{
MeshMap& meshMap = pair.second.second;
meshMap.erase(static_cast<const NzSkeletalMesh*>(object));
}
break;
}
case ObjectType_Skeleton:
s_cache.erase(static_cast<const NzSkeleton*>(object));
break;
}
return false;
}
bool OnObjectModified(const NzRefCounted* object, int index, unsigned int code) override
{
NazaraUnused(code);
switch (index)
{
case ObjectType_SkeletalMesh:
{
for (auto& pair : s_cache)
{
MeshMap& meshMap = pair.second.second;
for (auto& pair2 : meshMap)
pair2.second.second.updated = false;
}
break;
}
case ObjectType_Skeleton:
{
const NzSkeleton* skeleton = static_cast<const NzSkeleton*>(object);
for (auto& pair : s_cache.at(skeleton).second)
pair.second.second.updated = false;
break;
}
}
return true;
}
void OnObjectReleased(const NzRefCounted* resource, int index) override
{
OnObjectDestroy(resource, index);
}
};
ObjectListener listener;
void Skin_MonoCPU(const NzSkeletalMesh* mesh, const NzSkeleton* skeleton, NzVertexBuffer* buffer) void Skin_MonoCPU(const NzSkeletalMesh* mesh, const NzSkeleton* skeleton, NzVertexBuffer* buffer)
{ {
@ -163,18 +105,28 @@ NzVertexBuffer* NzSkinningManager::GetBuffer(const NzSkeletalMesh* mesh, const N
SkeletonMap::iterator it = s_cache.find(skeleton); SkeletonMap::iterator it = s_cache.find(skeleton);
if (it == s_cache.end()) if (it == s_cache.end())
it = s_cache.insert(std::make_pair(skeleton, std::make_pair(NzSkeletonConstListener(&listener, ObjectType_Skeleton, skeleton), MeshMap{}))).first; {
MeshData meshData;
meshData.skeletonDestroySlot.Connect(skeleton->OnSkeletonDestroy, OnSkeletonRelease);
meshData.skeletonJointsInvalidatedSlot.Connect(skeleton->OnSkeletonJointsInvalidated, OnSkeletonInvalidated);
it = s_cache.insert(std::make_pair(skeleton, std::move(meshData))).first;
}
NzVertexBuffer* buffer; NzVertexBuffer* buffer;
MeshMap& meshMap = it->second.second; MeshMap& meshMap = it->second.meshMap;
MeshMap::iterator it2 = meshMap.find(mesh); MeshMap::iterator it2 = meshMap.find(mesh);
if (it2 == meshMap.end()) if (it2 == meshMap.end())
{ {
NzVertexBufferRef vertexBuffer = NzVertexBuffer::New(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), mesh->GetVertexCount(), nzDataStorage_Hardware, nzBufferUsage_Dynamic); NzVertexBufferRef vertexBuffer = NzVertexBuffer::New(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), mesh->GetVertexCount(), nzDataStorage_Hardware, nzBufferUsage_Dynamic);
BufferData data({vertexBuffer, true}); BufferData data;
meshMap.insert(std::make_pair(mesh, std::make_pair(NzSkeletalMeshConstListener(&listener, ObjectType_SkeletalMesh, mesh), data))); data.skeletalMeshDestroySlot.Connect(mesh->OnSkeletalMeshDestroy, OnSkeletalMeshDestroy);
data.buffer = vertexBuffer;
data.updated = true;
meshMap.insert(std::make_pair(mesh, std::move(data)));
s_skinningQueue.push_back(SkinningData{mesh, skeleton, vertexBuffer}); s_skinningQueue.push_back(SkinningData{mesh, skeleton, vertexBuffer});
@ -182,7 +134,7 @@ NzVertexBuffer* NzSkinningManager::GetBuffer(const NzSkeletalMesh* mesh, const N
} }
else else
{ {
BufferData& data = it2->second.second; BufferData& data = it2->second;
if (!data.updated) if (!data.updated)
{ {
s_skinningQueue.push_back(SkinningData{mesh, skeleton, data.buffer}); s_skinningQueue.push_back(SkinningData{mesh, skeleton, data.buffer});
@ -214,6 +166,26 @@ bool NzSkinningManager::Initialize()
return true; // Rien de particulier à faire return true; // Rien de particulier à faire
} }
void NzSkinningManager::OnSkeletalMeshDestroy(const NzSkeletalMesh* mesh)
{
for (auto& pair : s_cache)
{
MeshMap& meshMap = pair.second.meshMap;
meshMap.erase(mesh);
}
}
void NzSkinningManager::OnSkeletonInvalidated(const NzSkeleton* skeleton)
{
for (auto& pair : s_cache.at(skeleton).meshMap)
pair.second.updated = false;
}
void NzSkinningManager::OnSkeletonRelease(const NzSkeleton* skeleton)
{
s_cache.erase(skeleton);
}
void NzSkinningManager::Uninitialize() void NzSkinningManager::Uninitialize()
{ {
s_cache.clear(); s_cache.clear();

View File

@ -176,8 +176,6 @@ bool NzContext::Create(const NzContextParameters& parameters)
onExit.Reset(); onExit.Reset();
NotifyCreated();
return true; return true;
} }
@ -185,7 +183,7 @@ void NzContext::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); OnContextDestroy(this);
NzOpenGL::OnContextDestruction(this); NzOpenGL::OnContextDestruction(this);
SetActive(false); SetActive(false);

View File

@ -16,6 +16,8 @@ m_id(0)
NzRenderBuffer::~NzRenderBuffer() NzRenderBuffer::~NzRenderBuffer()
{ {
OnRenderBufferRelease(this);
Destroy(); Destroy();
} }
@ -67,7 +69,6 @@ bool NzRenderBuffer::Create(nzPixelFormat format, unsigned int width, unsigned i
m_id = renderBuffer; m_id = renderBuffer;
m_width = width; m_width = width;
NotifyCreated();
return true; return true;
} }
@ -75,7 +76,7 @@ void NzRenderBuffer::Destroy()
{ {
if (m_id) if (m_id)
{ {
NotifyDestroy(); OnRenderBufferDestroy(this);
NzContext::EnsureContext(); NzContext::EnsureContext();

View File

@ -9,7 +9,9 @@
#include <Nazara/Renderer/OpenGL.hpp> #include <Nazara/Renderer/OpenGL.hpp>
#include <Nazara/Renderer/Renderer.hpp> #include <Nazara/Renderer/Renderer.hpp>
#include <Nazara/Renderer/RenderBuffer.hpp> #include <Nazara/Renderer/RenderBuffer.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Utility/PixelFormat.hpp> #include <Nazara/Utility/PixelFormat.hpp>
#include <functional>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <vector> #include <vector>
@ -19,17 +21,11 @@ namespace
{ {
struct Attachment struct Attachment
{ {
Attachment(NzObjectListener* listener, int bufferIndex = 0, int textureIndex = 0) : NazaraSlot(NzRenderBuffer, OnRenderBufferDestroy, renderBufferDestroySlot);
bufferListener(listener, bufferIndex), NazaraSlot(NzTexture, OnTextureDestroy, textureDestroySlot);
textureListener(listener, textureIndex)
{
}
NzRenderBufferRef buffer; NzRenderBufferRef buffer;
NzTextureRef texture; NzTextureRef texture;
// Les listeners doivent se trouver après les références (pour être libérés avant elles)
NzRenderBufferListener bufferListener;
NzTextureListener textureListener;
nzAttachmentPoint attachmentPoint; nzAttachmentPoint attachmentPoint;
bool isBuffer; bool isBuffer;
@ -60,16 +56,13 @@ namespace
struct NzRenderTextureImpl struct NzRenderTextureImpl
{ {
NzRenderTextureImpl(NzObjectListener* listener, int contextIndex = 0) : NazaraSlot(NzContext, OnContextDestroy, contextDestroySlot);
context(listener, contextIndex)
{
}
GLuint fbo; GLuint fbo;
std::vector<Attachment> attachments; std::vector<Attachment> attachments;
std::vector<nzUInt8> colorTargets; std::vector<nzUInt8> colorTargets;
mutable std::vector<GLenum> drawBuffers; mutable std::vector<GLenum> drawBuffers;
NzContextConstListener context; const NzContext* context;
bool checked = false; bool checked = false;
bool complete = false; bool complete = false;
bool userDefinedTargets = false; bool userDefinedTargets = false;
@ -155,17 +148,10 @@ bool NzRenderTexture::AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 in
Unlock(); Unlock();
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; unsigned int attachIndex = attachmentIndex[attachmentPoint] + index;
// On créé les attachements si ça n'a pas déjà été fait
for (unsigned int i = m_impl->attachments.size(); i <= attachIndex; ++i)
{
Attachment attachment(this, attachIndex, attachIndex);
m_impl->attachments.emplace_back(std::move(attachment));
}
Attachment& attachment = m_impl->attachments[attachIndex]; Attachment& attachment = m_impl->attachments[attachIndex];
attachment.attachmentPoint = attachmentPoint; attachment.attachmentPoint = attachmentPoint;
attachment.buffer = buffer; attachment.buffer = buffer;
attachment.bufferListener = buffer; attachment.renderBufferDestroySlot.Connect(buffer->OnRenderBufferDestroy, std::bind(OnRenderBufferDestroy, this, std::placeholders::_1, attachIndex));
attachment.isBuffer = true; attachment.isBuffer = true;
attachment.isUsed = true; attachment.isUsed = true;
attachment.height = buffer->GetHeight(); attachment.height = buffer->GetHeight();
@ -300,21 +286,13 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
Unlock(); Unlock();
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; unsigned int attachIndex = attachmentIndex[attachmentPoint] + index;
// On créé les attachements si ça n'a pas déjà été fait
for (unsigned int i = m_impl->attachments.size(); i <= attachIndex; ++i)
{
Attachment attachment(this, attachIndex, attachIndex);
m_impl->attachments.emplace_back(std::move(attachment));
}
Attachment& attachment = m_impl->attachments[attachIndex]; Attachment& attachment = m_impl->attachments[attachIndex];
attachment.attachmentPoint = attachmentPoint; attachment.attachmentPoint = attachmentPoint;
attachment.isBuffer = false; attachment.isBuffer = false;
attachment.isUsed = true; attachment.isUsed = true;
attachment.height = texture->GetHeight(); attachment.height = texture->GetHeight();
attachment.texture = texture; attachment.texture = texture;
attachment.textureListener = texture; attachment.textureDestroySlot.Connect(texture->OnTextureDestroy, std::bind(OnTextureDestroy, this, std::placeholders::_1, attachIndex));
attachment.width = texture->GetWidth(); attachment.width = texture->GetWidth();
m_impl->checked = false; m_impl->checked = false;
@ -348,7 +326,7 @@ bool NzRenderTexture::Create(bool lock)
} }
#endif #endif
std::unique_ptr<NzRenderTextureImpl> impl(new NzRenderTextureImpl(this)); std::unique_ptr<NzRenderTextureImpl> impl(new NzRenderTextureImpl);
impl->fbo = 0; impl->fbo = 0;
glGenFramebuffers(1, &impl->fbo); glGenFramebuffers(1, &impl->fbo);
@ -361,6 +339,7 @@ bool NzRenderTexture::Create(bool lock)
m_impl = impl.release(); m_impl = impl.release();
m_impl->context = NzContext::GetCurrent(); m_impl->context = NzContext::GetCurrent();
m_impl->contextDestroySlot.Connect(m_impl->context->OnContextDestroy, this, OnContextDestroy);
if (lock) if (lock)
{ {
@ -437,8 +416,8 @@ void NzRenderTexture::Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index)
{ {
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, NzOpenGL::Attachment[attachmentPoint]+index, GL_RENDERBUFFER, 0); glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, NzOpenGL::Attachment[attachmentPoint]+index, GL_RENDERBUFFER, 0);
attachement.bufferListener = nullptr;
attachement.buffer = nullptr; attachement.buffer = nullptr;
attachement.renderBufferDestroySlot.Disconnect();
} }
else else
{ {
@ -447,8 +426,8 @@ void NzRenderTexture::Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index)
else else
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, NzOpenGL::Attachment[attachmentPoint]+index, 0, 0, 0); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, NzOpenGL::Attachment[attachmentPoint]+index, 0, 0, 0);
attachement.textureListener = nullptr;
attachement.texture = nullptr; attachement.texture = nullptr;
attachement.textureDestroySlot.Disconnect();
} }
m_impl->sizeUpdated = false; m_impl->sizeUpdated = false;
@ -887,27 +866,52 @@ void NzRenderTexture::EnsureTargetUpdated() const
} }
} }
bool NzRenderTexture::OnObjectDestroy(const NzRefCounted* object, int index) void NzRenderTexture::OnContextDestroy(const NzContext* context)
{ {
if (object == m_impl->context) NazaraAssert(m_impl, "Invalid internal state");
// Notre contexte va être détruit, libérons la RenderTexture pour éviter un éventuel leak NazaraUnused(context);
Destroy();
else // Sinon, c'est une texture #ifdef NAZARA_DEBUG
if (m_impl->context != context)
{ {
// La ressource n'est plus, du coup nous mettons à jour NazaraInternalError("Not listening to " + NzString::Pointer(font));
Attachment& attachment = m_impl->attachments[index]; return;
if (attachment.isBuffer)
attachment.buffer = nullptr;
else
attachment.texture = nullptr;
attachment.isUsed = false;
m_impl->checked = false;
m_impl->targetsUpdated = false;
} }
#endif
return false; Destroy();
}
void NzRenderTexture::OnRenderBufferDestroy(const NzRenderBuffer* renderBuffer, int attachmentIndex)
{
NazaraAssert(m_impl, "Invalid internal state");
NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index");
NazaraAssert(m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state");
NazaraUnused(renderBuffer);
Attachment& attachment = m_impl->attachments[attachmentIndex];
attachment.buffer = nullptr;
attachment.isUsed = false;
attachment.renderBufferDestroySlot.Disconnect();
m_impl->checked = false;
m_impl->targetsUpdated = false;
}
void NzRenderTexture::OnTextureDestroy(const NzTexture* texture, int attachmentIndex)
{
NazaraAssert(m_impl, "Invalid internal state");
NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index");
NazaraAssert(!m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state");
NazaraUnused(texture);
Attachment& attachment = m_impl->attachments[attachmentIndex];
attachment.isUsed = false;
attachment.texture = nullptr;
attachment.textureDestroySlot.Disconnect();
m_impl->checked = false;
m_impl->targetsUpdated = false;
} }
void NzRenderTexture::UpdateDrawBuffers() const void NzRenderTexture::UpdateDrawBuffers() const

View File

@ -178,9 +178,14 @@ bool NzShader::Create()
void NzShader::Destroy() void NzShader::Destroy()
{ {
NzContext::EnsureContext(); if (m_program)
{
OnShaderDestroy(this);
NzOpenGL::DeleteProgram(m_program); NzContext::EnsureContext();
NzOpenGL::DeleteProgram(m_program);
m_program = 0;
}
} }
NzByteArray NzShader::GetBinary() const NzByteArray NzShader::GetBinary() const

View File

@ -202,8 +202,6 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt
} }
onExit.Reset(); onExit.Reset();
NotifyCreated();
return true; return true;
} }
@ -211,7 +209,7 @@ void NzTexture::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); OnTextureDestroy(this);
NzContext::EnsureContext(); NzContext::EnsureContext();
NzOpenGL::DeleteTexture(m_impl->id); NzOpenGL::DeleteTexture(m_impl->id);

View File

@ -5,7 +5,10 @@
#include <Nazara/Renderer/UberShader.hpp> #include <Nazara/Renderer/UberShader.hpp>
#include <Nazara/Renderer/Debug.hpp> #include <Nazara/Renderer/Debug.hpp>
NzUberShader::~NzUberShader() = default; NzUberShader::~NzUberShader()
{
OnUberShaderRelease(this);
}
bool NzUberShader::Initialize() bool NzUberShader::Initialize()
{ {

View File

@ -10,6 +10,11 @@
#include <memory> #include <memory>
#include <Nazara/Renderer/Debug.hpp> #include <Nazara/Renderer/Debug.hpp>
NzUberShaderPreprocessor::~NzUberShaderPreprocessor()
{
OnUberShaderPreprocessorRelease(this);
}
NzUberShaderInstance* NzUberShaderPreprocessor::Get(const NzParameterList& parameters) const NzUberShaderInstance* NzUberShaderPreprocessor::Get(const NzParameterList& parameters) const
{ {
// Première étape, transformer les paramètres en un flag // Première étape, transformer les paramètres en un flag

View File

@ -34,7 +34,7 @@ bool NzAnimationParams::IsValid() const
NzAnimation::~NzAnimation() NzAnimation::~NzAnimation()
{ {
Destroy(); OnAnimationRelease(this);
} }
bool NzAnimation::AddSequence(const NzSequence& sequence) bool NzAnimation::AddSequence(const NzSequence& sequence)
@ -172,7 +172,6 @@ bool NzAnimation::CreateSkeletal(unsigned int frameCount, unsigned int jointCoun
m_impl->sequenceJoints.resize(frameCount*jointCount); m_impl->sequenceJoints.resize(frameCount*jointCount);
m_impl->type = nzAnimationType_Skeletal; m_impl->type = nzAnimationType_Skeletal;
NotifyCreated();
return true; return true;
} }
@ -180,7 +179,7 @@ void NzAnimation::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); OnAnimationDestroy(this);
delete m_impl; delete m_impl;
m_impl = nullptr; m_impl = nullptr;

View File

@ -40,6 +40,8 @@ m_impl(nullptr)
NzBuffer::~NzBuffer() NzBuffer::~NzBuffer()
{ {
OnBufferRelease(this);
Destroy(); Destroy();
} }
@ -86,7 +88,6 @@ bool NzBuffer::Create(unsigned int size, nzUInt32 storage, nzBufferUsage usage)
m_storage = storage; m_storage = storage;
m_usage = usage; m_usage = usage;
NotifyCreated();
return true; // Si on arrive ici c'est que tout s'est bien passé. return true; // Si on arrive ici c'est que tout s'est bien passé.
} }
@ -94,7 +95,7 @@ void NzBuffer::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); OnBufferDestroy(this);
m_impl->Destroy(); m_impl->Destroy();
delete m_impl; delete m_impl;

View File

@ -90,17 +90,21 @@ bool NzFont::Create(NzFontData* data)
#endif #endif
m_data.reset(data); m_data.reset(data);
return true; return true;
} }
void NzFont::Destroy() void NzFont::Destroy()
{ {
ClearGlyphCache(); if (m_data)
{
OnFontDestroy(this);
m_data.reset(); ClearGlyphCache();
m_kerningCache.clear();
m_sizeInfoCache.clear(); m_data.reset();
m_kerningCache.clear();
m_sizeInfoCache.clear();
}
} }
bool NzFont::ExtractGlyph(unsigned int characterSize, char32_t character, nzUInt32 style, NzFontGlyph* glyph) const bool NzFont::ExtractGlyph(unsigned int characterSize, char32_t character, nzUInt32 style, NzFontGlyph* glyph) const

View File

@ -65,6 +65,8 @@ m_sharedImage(sharedImage)
NzImage::~NzImage() NzImage::~NzImage()
{ {
OnImageRelease(this);
Destroy(); Destroy();
} }
@ -306,7 +308,6 @@ bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width,
m_sharedImage = new SharedImage(1, type, format, levelCount, levels, width, height, depth); m_sharedImage = new SharedImage(1, type, format, levelCount, levels, width, height, depth);
NotifyCreated();
return true; return true;
} }
@ -314,7 +315,7 @@ void NzImage::Destroy()
{ {
if (m_sharedImage != &emptyImage) if (m_sharedImage != &emptyImage)
{ {
NotifyDestroy(); OnImageDestroy(this);
ReleaseImage(); ReleaseImage();
} }
} }

View File

@ -66,6 +66,8 @@ struct NzMeshImpl
NzMesh::~NzMesh() NzMesh::~NzMesh()
{ {
OnMeshRelease(this);
Destroy(); Destroy();
} }
@ -359,7 +361,6 @@ bool NzMesh::CreateSkeletal(unsigned int jointCount)
return false; return false;
} }
NotifyCreated();
return true; return true;
} }
@ -370,7 +371,6 @@ bool NzMesh::CreateStatic()
m_impl = new NzMeshImpl; m_impl = new NzMeshImpl;
m_impl->animationType = nzAnimationType_Static; m_impl->animationType = nzAnimationType_Static;
NotifyCreated();
return true; return true;
} }
@ -378,7 +378,7 @@ void NzMesh::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); OnMeshDestroy(this);
delete m_impl; delete m_impl;
m_impl = nullptr; m_impl = nullptr;

View File

@ -24,6 +24,8 @@ m_characterSize(drawer.m_characterSize)
SetFont(drawer.m_font); SetFont(drawer.m_font);
} }
NzSimpleTextDrawer::~NzSimpleTextDrawer() = default;
const NzRectui& NzSimpleTextDrawer::GetBounds() const const NzRectui& NzSimpleTextDrawer::GetBounds() const
{ {
if (!m_glyphUpdated) if (!m_glyphUpdated)

View File

@ -16,6 +16,8 @@ NzSubMesh(parent)
NzSkeletalMesh::~NzSkeletalMesh() NzSkeletalMesh::~NzSkeletalMesh()
{ {
OnSkeletalMeshRelease(this);
Destroy(); Destroy();
} }
@ -39,7 +41,7 @@ void NzSkeletalMesh::Destroy()
{ {
if (m_vertexBuffer) if (m_vertexBuffer)
{ {
NotifyDestroy(); OnSkeletalMeshDestroy(this);
m_indexBuffer.Reset(); m_indexBuffer.Reset();
m_vertexBuffer.Reset(); m_vertexBuffer.Reset();

View File

@ -24,6 +24,8 @@ m_impl(nullptr)
NzSkeleton::~NzSkeleton() NzSkeleton::~NzSkeleton()
{ {
OnSkeletonRelease(this);
Destroy(); Destroy();
} }
@ -47,6 +49,8 @@ void NzSkeleton::Destroy()
{ {
if (m_impl) if (m_impl)
{ {
OnSkeletonDestroy(this);
delete m_impl; delete m_impl;
m_impl = nullptr; m_impl = nullptr;
} }
@ -372,7 +376,8 @@ NzSkeleton& NzSkeleton::operator=(const NzSkeleton& skeleton)
void NzSkeleton::InvalidateJoints() void NzSkeleton::InvalidateJoints()
{ {
m_impl->aabbUpdated = false; m_impl->aabbUpdated = false;
NotifyModified(0);
OnSkeletonJointsInvalidated(this);
} }
void NzSkeleton::InvalidateJointMap() void NzSkeleton::InvalidateJointMap()

View File

@ -18,6 +18,8 @@ NzSubMesh(parent)
NzStaticMesh::~NzStaticMesh() NzStaticMesh::~NzStaticMesh()
{ {
OnStaticMeshRelease(this);
Destroy(); Destroy();
} }
@ -57,7 +59,7 @@ void NzStaticMesh::Destroy()
{ {
if (m_vertexBuffer) if (m_vertexBuffer)
{ {
NotifyDestroy(); OnStaticMeshDestroy(this);
m_indexBuffer.Reset(); m_indexBuffer.Reset();
m_vertexBuffer.Reset(); m_vertexBuffer.Reset();

View File

@ -20,7 +20,10 @@ m_matIndex(0)
{ {
} }
NzSubMesh::~NzSubMesh() = default; NzSubMesh::~NzSubMesh()
{
OnSubMeshRelease(this);
}
void NzSubMesh::GenerateNormals() void NzSubMesh::GenerateNormals()
{ {