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

View File

@ -64,8 +64,6 @@
#include <Nazara/Core/Mutex.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/OffsetOf.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>
#endif
class NzObjectListener;
class NAZARA_API NzRefCounted
{
public:
NzRefCounted(bool persistent = true);
NzRefCounted(const NzRefCounted&) = delete;
NzRefCounted(NzRefCounted&&) = delete;
NzRefCounted(NzRefCounted&&) = default;
virtual ~NzRefCounted();
void AddObjectListener(NzObjectListener* listener, int index = 0) const;
void AddReference() const;
unsigned int GetReferenceCount() const;
bool IsPersistent() const;
void RemoveObjectListener(NzObjectListener* listener) const;
bool RemoveReference() const;
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
NzRefCounted& operator=(const NzRefCounted&) = delete;
NzRefCounted& operator=(NzRefCounted&&) = delete;
protected:
void NotifyCreated();
void NotifyDestroy();
void NotifyModified(unsigned int code);
NzRefCounted& operator=(NzRefCounted&&) = default;
private:
using ObjectListenerMap = std::unordered_map<NzObjectListener*, std::pair<int, unsigned int>>;
NazaraMutexAttrib(m_mutex, mutable)
mutable ObjectListenerMap m_objectListeners;
std::atomic_bool m_persistent;
mutable std::atomic_uint m_referenceCount;
bool m_objectListenersLocked;
};
#endif // NAZARA_RESOURCE_HPP

View File

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

View File

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

View File

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

View File

@ -9,18 +9,16 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
class NzParticleController;
class NzParticleMapper;
class NzParticleSystem;
using NzParticleControllerConstListener = NzObjectListenerWrapper<const NzParticleController>;
using NzParticleControllerConstRef = NzObjectRef<const NzParticleController>;
using NzParticleControllerLibrary = NzObjectLibrary<NzParticleController>;
using NzParticleControllerListener = NzObjectListenerWrapper<NzParticleController>;
using NzParticleControllerRef = NzObjectRef<NzParticleController>;
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;
// Signals:
NazaraSignal(OnParticleControllerRelease, const NzParticleController*); //< Args: me
private:
static bool Initialize();
static void Uninitialize();

View File

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

View File

@ -9,18 +9,16 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
class NzParticleGenerator;
class NzParticleMapper;
class NzParticleSystem;
using NzParticleGeneratorConstListener = NzObjectListenerWrapper<const NzParticleGenerator>;
using NzParticleGeneratorConstRef = NzObjectRef<const NzParticleGenerator>;
using NzParticleGeneratorLibrary = NzObjectLibrary<NzParticleGenerator>;
using NzParticleGeneratorListener = NzObjectListenerWrapper<NzParticleGenerator>;
using NzParticleGeneratorRef = NzObjectRef<NzParticleGenerator>;
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;
// Signals:
NazaraSignal(OnParticleGeneratorRelease, const NzParticleGenerator*); //< Args: me
private:
static bool Initialize();
static void Uninitialize();

View File

@ -9,19 +9,17 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
class NzAbstractRenderQueue;
class NzParticleMapper;
class NzParticleRenderer;
class NzParticleSystem;
using NzParticleRendererConstListener = NzObjectListenerWrapper<const NzParticleRenderer>;
using NzParticleRendererConstRef = NzObjectRef<const NzParticleRenderer>;
using NzParticleRendererLibrary = NzObjectLibrary<NzParticleRenderer>;
using NzParticleRendererListener = NzObjectListenerWrapper<NzParticleRenderer>;
using NzParticleRendererRef = NzObjectRef<NzParticleRenderer>;
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;
// Signals:
NazaraSignal(OnParticleRendererRelease, const NzParticleRenderer*); //< Args: me
private:
static bool Initialize();
static void Uninitialize();

View File

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

View File

@ -28,6 +28,9 @@ class NAZARA_API NzSkinningManager
private:
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 SkinFunction s_skinFunc;

View File

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

View File

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

View File

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

View File

@ -9,18 +9,21 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.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)
class NzContext;
class NzRenderBuffer;
class NzTexture;
struct NzRenderTextureImpl;
class NAZARA_API NzRenderTexture : public NzRenderTarget, NzObjectListener, NzNonCopyable
class NAZARA_API NzRenderTexture : public NzRenderTarget, NzNonCopyable
{
public:
NzRenderTexture() = default;
@ -66,7 +69,9 @@ class NAZARA_API NzRenderTexture : public NzRenderTarget, NzObjectListener, NzNo
void EnsureTargetUpdated() const override;
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 UpdateSize() const;
void UpdateTargets() const;

View File

@ -12,7 +12,6 @@
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
@ -26,10 +25,8 @@
class NzShader;
class NzShaderStage;
using NzShaderConstListener = NzObjectListenerWrapper<const NzShader>;
using NzShaderConstRef = NzObjectRef<const NzShader>;
using NzShaderLibrary = NzObjectLibrary<NzShader>;
using NzShaderListener = NzObjectListenerWrapper<NzShader>;
using NzShaderRef = NzObjectRef<NzShader>;
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);
// Signals
NazaraSignal(OnShaderDestroy, const NzShader*); //< Args: me
NazaraSignal(OnShaderRelease, const NzShader*); //< Args: me
NazaraSignal(OnShaderUniformInvalidated, const NzShader*); //< Args: me

View File

@ -10,7 +10,6 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp>
@ -23,10 +22,8 @@
class NzTexture;
using NzTextureConstListener = NzObjectListenerWrapper<const NzTexture>;
using NzTextureConstRef = NzObjectRef<const NzTexture>;
using NzTextureLibrary = NzObjectLibrary<NzTexture>;
using NzTextureListener = NzObjectListenerWrapper<NzTexture>;
using NzTextureManager = NzResourceManager<NzTexture, NzImageParams>;
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);
// Signals
NazaraSignal(OnTextureDestroy, const NzTexture*); //< Args: me
NazaraSignal(OnTextureRelease, const NzTexture*); //< Args: me
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,15 +8,13 @@
#define NAZARA_SKELETALMESH_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/SubMesh.hpp>
class NzSkeletalMesh;
using NzSkeletalMeshConstListener = NzObjectListenerWrapper<const NzSkeletalMesh>;
using NzSkeletalMeshConstRef = NzObjectRef<const NzSkeletalMesh>;
using NzSkeletalMeshListener = NzObjectListenerWrapper<NzSkeletalMesh>;
using NzSkeletalMeshRef = NzObjectRef<NzSkeletalMesh>;
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);
// Signals:
NazaraSignal(OnSkeletalMeshDestroy, const NzSkeletalMesh*); //< Args: me
NazaraSignal(OnSkeletalMeshRelease, const NzSkeletalMesh*); //< Args: me
private:
NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr;

View File

@ -9,19 +9,17 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Utility/Joint.hpp>
#include <vector>
class NzSkeleton;
using NzSkeletonConstListener = NzObjectListenerWrapper<const NzSkeleton>;
using NzSkeletonConstRef = NzObjectRef<const NzSkeleton>;
using NzSkeletonLibrary = NzObjectLibrary<NzSkeleton>;
using NzSkeletonListener = NzObjectListenerWrapper<NzSkeleton>;
using NzSkeletonRef = NzObjectRef<NzSkeleton>;
struct NzSkeletonImpl;
@ -59,6 +57,11 @@ class NAZARA_API NzSkeleton : public NzRefCounted
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:
void InvalidateJoints();
void InvalidateJointMap();

View File

@ -8,15 +8,12 @@
#define NAZARA_STATICMESH_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/SubMesh.hpp>
class NzStaticMesh;
using NzStaticMeshConstListener = NzObjectListenerWrapper<const NzStaticMesh>;
using NzStaticMeshConstRef = NzObjectRef<const NzStaticMesh>;
using NzStaticMeshListener = NzObjectListenerWrapper<NzStaticMesh>;
using NzStaticMeshRef = NzObjectRef<NzStaticMesh>;
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);
// Signals:
NazaraSignal(OnStaticMeshDestroy, const NzStaticMesh*); //< Args: me
NazaraSignal(OnStaticMeshRelease, const NzStaticMesh*); //< Args: me
private:
NzBoxf m_aabb;
NzIndexBufferConstRef m_indexBuffer = nullptr;

View File

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

View File

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

View File

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

View File

@ -44,6 +44,8 @@ NzSoundBuffer::NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, uns
NzSoundBuffer::~NzSoundBuffer()
{
OnSoundBufferRelease(this);
Destroy();
}
@ -108,7 +110,6 @@ bool NzSoundBuffer::Create(nzAudioFormat format, unsigned int sampleCount, unsig
m_impl->samples.reset(new nzInt16[sampleCount]);
std::memcpy(&m_impl->samples[0], samples, sampleCount*sizeof(nzInt16));
NotifyCreated();
return true;
}
@ -116,7 +117,7 @@ void NzSoundBuffer::Destroy()
{
if (m_impl)
{
NotifyDestroy();
OnSoundBufferDestroy(this);
delete m_impl;
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/Config.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED
#include <Nazara/Core/ThreadSafety.hpp>
@ -17,36 +16,18 @@
NzRefCounted::NzRefCounted(bool persistent) :
m_persistent(persistent),
m_referenceCount(0),
m_objectListenersLocked(false)
m_referenceCount(0)
{
}
NzRefCounted::~NzRefCounted()
{
m_objectListenersLocked = true;
for (auto& pair : m_objectListeners)
pair.first->OnObjectReleased(this, pair.second.first);
#if NAZARA_CORE_SAFE
if (m_referenceCount > 0)
NazaraWarning("Resource destroyed while still referenced " + NzString::Number(m_referenceCount) + " time(s)");
#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
{
m_referenceCount++;
@ -62,23 +43,6 @@ bool NzRefCounted::IsPersistent() const
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
{
#if NAZARA_CORE_SAFE
@ -113,56 +77,3 @@ bool NzRefCounted::SetPersistent(bool persistent, bool checkReferenceCount)
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()
{
NotifyDestroy();
OnMaterialReset(this);
m_alphaMap.Reset();
m_diffuseMap.Reset();

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,10 @@
#include <Nazara/Graphics/Renderable.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
{

View File

@ -4,7 +4,6 @@
#include <Nazara/Graphics/SkinningManager.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/TaskScheduler.hpp>
#include <Nazara/Utility/Algorithm.hpp>
#include <Nazara/Utility/SkeletalMesh.hpp>
@ -16,18 +15,24 @@
namespace
{
enum ObjectType
{
ObjectType_SkeletalMesh,
ObjectType_Skeleton,
};
struct BufferData
{
NazaraSlot(NzSkeletalMesh, OnSkeletalMeshDestroy, skeletalMeshDestroySlot);
NzVertexBufferRef buffer;
bool updated;
};
using MeshMap = std::unordered_map<const NzSkeletalMesh*, BufferData>;
struct MeshData
{
NazaraSlot(NzSkeleton, OnSkeletonDestroy, skeletonDestroySlot);
NazaraSlot(NzSkeleton, OnSkeletonJointsInvalidated, skeletonJointsInvalidatedSlot);
MeshMap meshMap;
};
struct SkinningData
{
const NzSkeletalMesh* mesh;
@ -35,73 +40,10 @@ namespace
NzVertexBuffer* buffer;
};
using MeshMap = std::unordered_map<const NzSkeletalMesh*, std::pair<NzSkeletalMeshConstListener, BufferData>>;
using SkeletonMap = std::unordered_map<const NzSkeleton*, std::pair<NzSkeletonConstListener, MeshMap>>;
using SkeletonMap = std::unordered_map<const NzSkeleton*, MeshData>;
SkeletonMap s_cache;
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)
{
@ -163,18 +105,28 @@ NzVertexBuffer* NzSkinningManager::GetBuffer(const NzSkeletalMesh* mesh, const N
SkeletonMap::iterator it = s_cache.find(skeleton);
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;
MeshMap& meshMap = it->second.second;
MeshMap& meshMap = it->second.meshMap;
MeshMap::iterator it2 = meshMap.find(mesh);
if (it2 == meshMap.end())
{
NzVertexBufferRef vertexBuffer = NzVertexBuffer::New(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), mesh->GetVertexCount(), nzDataStorage_Hardware, nzBufferUsage_Dynamic);
BufferData data({vertexBuffer, true});
meshMap.insert(std::make_pair(mesh, std::make_pair(NzSkeletalMeshConstListener(&listener, ObjectType_SkeletalMesh, mesh), data)));
BufferData 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});
@ -182,7 +134,7 @@ NzVertexBuffer* NzSkinningManager::GetBuffer(const NzSkeletalMesh* mesh, const N
}
else
{
BufferData& data = it2->second.second;
BufferData& data = it2->second;
if (!data.updated)
{
s_skinningQueue.push_back(SkinningData{mesh, skeleton, data.buffer});
@ -214,6 +166,26 @@ bool NzSkinningManager::Initialize()
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()
{
s_cache.clear();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ bool NzAnimationParams::IsValid() const
NzAnimation::~NzAnimation()
{
Destroy();
OnAnimationRelease(this);
}
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->type = nzAnimationType_Skeletal;
NotifyCreated();
return true;
}
@ -180,7 +179,7 @@ void NzAnimation::Destroy()
{
if (m_impl)
{
NotifyDestroy();
OnAnimationDestroy(this);
delete m_impl;
m_impl = nullptr;

View File

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

View File

@ -90,18 +90,22 @@ bool NzFont::Create(NzFontData* data)
#endif
m_data.reset(data);
return true;
}
void NzFont::Destroy()
{
if (m_data)
{
OnFontDestroy(this);
ClearGlyphCache();
m_data.reset();
m_kerningCache.clear();
m_sizeInfoCache.clear();
}
}
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()
{
OnImageRelease(this);
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);
NotifyCreated();
return true;
}
@ -314,7 +315,7 @@ void NzImage::Destroy()
{
if (m_sharedImage != &emptyImage)
{
NotifyDestroy();
OnImageDestroy(this);
ReleaseImage();
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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