Renderer/Renderer: Replace listeners by signals
Former-commit-id: c1293f7f7cc31c4122ba866fc44d93188917ad93
This commit is contained in:
parent
022f082363
commit
004b53c590
|
|
@ -140,7 +140,7 @@ namespace Ndk
|
|||
{
|
||||
m_target = renderTarget;
|
||||
if (m_target)
|
||||
m_targetReleaseSlot = NazaraConnect(*m_target, OnRenderTargetRelease, OnRenderTargetRelease);
|
||||
m_targetReleaseSlot = NazaraConnectThis(*m_target, OnRenderTargetRelease, OnRenderTargetRelease);
|
||||
else
|
||||
NazaraDisconnect(m_targetReleaseSlot);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Ndk
|
|||
void CameraComponent::OnAttached()
|
||||
{
|
||||
if (m_entity->HasComponent<NodeComponent>())
|
||||
m_nodeInvalidationSlot = NazaraConnect(m_entity->GetComponent<NodeComponent>(), OnNodeInvalidation, OnNodeInvalidated);
|
||||
m_nodeInvalidationSlot = NazaraConnectThis(m_entity->GetComponent<NodeComponent>(), OnNodeInvalidation, OnNodeInvalidated);
|
||||
|
||||
InvalidateViewMatrix();
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ namespace Ndk
|
|||
if (IsComponent<NodeComponent>(component))
|
||||
{
|
||||
NodeComponent& nodeComponent = static_cast<NodeComponent&>(component);
|
||||
m_nodeInvalidationSlot = NazaraConnect(nodeComponent, OnNodeInvalidation, OnNodeInvalidated);
|
||||
m_nodeInvalidationSlot = NazaraConnectThis(nodeComponent, OnNodeInvalidation, OnNodeInvalidated);
|
||||
|
||||
InvalidateViewMatrix();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
#define NazaraSlotType(Class, SignalName) Class::SignalName ## Type::ConnectionGuard
|
||||
#define NazaraSlot(Class, SignalName, SlotName) NazaraSlotType(Class, SignalName) SlotName
|
||||
|
||||
#define NazaraConnect(Instance, SignalName, Callback) (Instance).SignalName.Connect(this, Callback)
|
||||
#define NazaraConnect(Instance, SignalName, Callback) (Instance).SignalName.Connect(Callback)
|
||||
#define NazaraConnectThis(Instance, SignalName, Callback) (Instance).SignalName.Connect(this, Callback)
|
||||
#define NazaraDisconnect(SlotName) SlotName.GetConnection().Disconnect()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <Nazara/Core/ObjectListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
|
@ -49,6 +50,8 @@ class NAZARA_API NzContext : public NzRefCounted
|
|||
static const NzContext* GetReference();
|
||||
static const NzContext* GetThreadContext();
|
||||
|
||||
NazaraSignal(OnContextRelease, const NzContext*); //< me
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
|
|
|||
|
|
@ -110,8 +110,12 @@ class NAZARA_API NzRenderer
|
|||
private:
|
||||
static void EnableInstancing(bool instancing);
|
||||
static bool EnsureStateUpdate();
|
||||
static void OnContextRelease(const NzContext* context);
|
||||
static void OnIndexBufferRelease(const NzIndexBuffer* indexBuffer);
|
||||
static void OnShaderReleased(const NzShader* shader);
|
||||
static void OnTextureReleased(const NzTexture* texture);
|
||||
static void OnVertexBufferRelease(const NzVertexBuffer* vertexBuffer);
|
||||
static void OnVertexDeclarationRelease(const NzVertexDeclaration* vertexDeclaration);
|
||||
static void UpdateMatrix(nzMatrixType type);
|
||||
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#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;
|
||||
|
|
@ -66,6 +67,8 @@ class NAZARA_API NzIndexBuffer : public NzRefCounted
|
|||
|
||||
template<typename... Args> static NzIndexBufferRef New(Args&&... args);
|
||||
|
||||
NazaraSignal(OnIndexBufferRelease, const NzIndexBuffer*); //< me
|
||||
|
||||
private:
|
||||
NzBufferRef m_buffer;
|
||||
bool m_largeIndices;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <Nazara/Core/ObjectListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
|
|
@ -64,6 +65,8 @@ class NAZARA_API NzVertexBuffer : public NzRefCounted
|
|||
|
||||
template<typename... Args> static NzVertexBufferRef New(Args&&... args);
|
||||
|
||||
NazaraSignal(OnVertexBufferRelease, const NzVertexBuffer*); //< me
|
||||
|
||||
private:
|
||||
NzBufferRef m_buffer;
|
||||
NzVertexDeclarationConstRef m_vertexDeclaration;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#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 NzVertexDeclaration;
|
||||
|
|
@ -46,6 +47,8 @@ class NAZARA_API NzVertexDeclaration : public NzRefCounted
|
|||
static bool IsTypeSupported(nzComponentType type);
|
||||
template<typename... Args> static NzVertexDeclarationRef New(Args&&... args);
|
||||
|
||||
NazaraSignal(OnVertexDeclarationRelease, const NzVertexDeclaration*); //< me
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ void NzCamera::SetTarget(const NzRenderTarget* renderTarget)
|
|||
|
||||
if (m_target)
|
||||
{
|
||||
m_targetReleaseSlot = NazaraConnect(*m_target, OnRenderTargetRelease, OnRenderTargetRelease);
|
||||
m_targetResizeSlot = NazaraConnect(*m_target, OnRenderTargetSizeChange, OnRenderTargetSizeChange);
|
||||
m_targetReleaseSlot = NazaraConnectThis(*m_target, OnRenderTargetRelease, OnRenderTargetRelease);
|
||||
m_targetResizeSlot = NazaraConnectThis(*m_target, OnRenderTargetSizeChange, OnRenderTargetSizeChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ m_verticesUpdated(sprite.m_verticesUpdated)
|
|||
const NzAbstractAtlas* atlas = it->first;
|
||||
AtlasSlots& slots = m_atlases[atlas];
|
||||
|
||||
slots.clearSlot = NazaraConnect(*atlas, OnAtlasCleared, OnAtlasInvalidated);
|
||||
slots.layerChangeSlot = NazaraConnect(*atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
slots.releaseSlot = NazaraConnect(*atlas, OnAtlasRelease, OnAtlasInvalidated);
|
||||
slots.clearSlot = NazaraConnectThis(*atlas, OnAtlasCleared, OnAtlasInvalidated);
|
||||
slots.layerChangeSlot = NazaraConnectThis(*atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
slots.releaseSlot = NazaraConnectThis(*atlas, OnAtlasRelease, OnAtlasInvalidated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,9 +153,9 @@ void NzTextSprite::Update(const NzAbstractTextDrawer& drawer)
|
|||
{
|
||||
AtlasSlots& slots = m_atlases[atlas];
|
||||
|
||||
slots.clearSlot = NazaraConnect(*atlas, OnAtlasCleared, OnAtlasInvalidated);
|
||||
slots.layerChangeSlot = NazaraConnect(*atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
slots.releaseSlot = NazaraConnect(*atlas, OnAtlasRelease, OnAtlasInvalidated);
|
||||
slots.clearSlot = NazaraConnectThis(*atlas, OnAtlasCleared, OnAtlasInvalidated);
|
||||
slots.layerChangeSlot = NazaraConnectThis(*atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
slots.releaseSlot = NazaraConnectThis(*atlas, OnAtlasRelease, OnAtlasInvalidated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -277,9 +277,9 @@ NzTextSprite& NzTextSprite::operator=(const NzTextSprite& text)
|
|||
const NzAbstractAtlas* atlas = it->first;
|
||||
AtlasSlots& slots = m_atlases[atlas];
|
||||
|
||||
slots.clearSlot = NazaraConnect(*atlas, OnAtlasCleared, OnAtlasInvalidated);
|
||||
slots.layerChangeSlot = NazaraConnect(*atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
slots.releaseSlot = NazaraConnect(*atlas, OnAtlasRelease, OnAtlasInvalidated);
|
||||
slots.clearSlot = NazaraConnectThis(*atlas, OnAtlasCleared, OnAtlasInvalidated);
|
||||
slots.layerChangeSlot = NazaraConnectThis(*atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
slots.releaseSlot = NazaraConnectThis(*atlas, OnAtlasRelease, OnAtlasInvalidated);
|
||||
}
|
||||
|
||||
// On ne copie pas les sommets finaux car il est très probable que nos paramètres soient modifiés et qu'ils doivent être régénérés de toute façon
|
||||
|
|
|
|||
|
|
@ -218,8 +218,8 @@ void NzView::SetTarget(const NzRenderTarget* renderTarget)
|
|||
m_target = renderTarget;
|
||||
if (m_target)
|
||||
{
|
||||
m_targetReleaseSlot = NazaraConnect(*m_target, OnRenderTargetRelease, OnRenderTargetRelease);
|
||||
m_targetResizeSlot = NazaraConnect(*m_target, OnRenderTargetSizeChange, OnRenderTargetSizeChange);
|
||||
m_targetReleaseSlot = NazaraConnectThis(*m_target, OnRenderTargetRelease, OnRenderTargetRelease);
|
||||
m_targetResizeSlot = NazaraConnectThis(*m_target, OnRenderTargetSizeChange, OnRenderTargetSizeChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ namespace
|
|||
|
||||
NzContext::~NzContext()
|
||||
{
|
||||
OnContextRelease(this);
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/ObjectListener.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Context.hpp>
|
||||
#include <Nazara/Renderer/DebugDrawer.hpp>
|
||||
|
|
@ -85,19 +85,12 @@ namespace
|
|||
|
||||
struct VAO_Entry
|
||||
{
|
||||
VAO_Entry(NzObjectListener* listener, int indexBufferIndex, int vertexBufferIndex, int vertexDeclarationIndex, int instancingDeclarationIndex) :
|
||||
indexBufferListener(listener, indexBufferIndex),
|
||||
vertexBufferListener(listener, vertexBufferIndex),
|
||||
instancingDeclarationListener(listener, instancingDeclarationIndex),
|
||||
vertexDeclarationListener(listener, vertexDeclarationIndex)
|
||||
{
|
||||
}
|
||||
|
||||
GLuint vao;
|
||||
NzIndexBufferConstListener indexBufferListener;
|
||||
NzVertexBufferConstListener vertexBufferListener;
|
||||
NzVertexDeclarationConstListener instancingDeclarationListener;
|
||||
NzVertexDeclarationConstListener vertexDeclarationListener;
|
||||
|
||||
NazaraSlot(NzIndexBuffer, OnIndexBufferRelease, onIndexBufferReleaseSlot);
|
||||
NazaraSlot(NzVertexBuffer, OnVertexBufferRelease, onVertexBufferReleaseSlot);
|
||||
NazaraSlot(NzVertexDeclaration, OnVertexDeclarationRelease, onInstancingDeclarationReleaseSlot);
|
||||
NazaraSlot(NzVertexDeclaration, OnVertexDeclarationRelease, onVertexDeclarationReleaseSlot);
|
||||
};
|
||||
|
||||
using VAO_Key = std::tuple<const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*, const NzVertexDeclaration*>;
|
||||
|
|
@ -105,13 +98,9 @@ namespace
|
|||
|
||||
struct Context_Entry
|
||||
{
|
||||
Context_Entry(NzObjectListener* listener, int index) :
|
||||
contextListener(listener, index)
|
||||
{
|
||||
}
|
||||
|
||||
NzContextConstListener contextListener;
|
||||
VAO_Map vaoMap;
|
||||
|
||||
NazaraSlot(NzContext, OnContextRelease, onReleaseSlot);
|
||||
};
|
||||
|
||||
using Context_Map = std::unordered_map<const NzContext*, Context_Entry>;
|
||||
|
|
@ -140,123 +129,6 @@ namespace
|
|||
unsigned int s_maxTextureSize;
|
||||
unsigned int s_maxTextureUnit;
|
||||
unsigned int s_maxVertexAttribs;
|
||||
|
||||
class ObjectListener : public NzObjectListener
|
||||
{
|
||||
public:
|
||||
void OnObjectReleased(const NzRefCounted* object, int index) override
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case ObjectType_Context:
|
||||
{
|
||||
const NzContext* context = static_cast<const NzContext*>(object);
|
||||
s_vaos.erase(context);
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectType_IndexBuffer:
|
||||
{
|
||||
const NzIndexBuffer* indexBuffer = static_cast<const NzIndexBuffer*>(object);
|
||||
for (auto& pair : s_vaos)
|
||||
{
|
||||
const NzContext* context = pair.first;
|
||||
VAO_Map& vaos = pair.second.vaoMap;
|
||||
|
||||
auto it = vaos.begin();
|
||||
while (it != vaos.end())
|
||||
{
|
||||
const VAO_Key& key = it->first;
|
||||
const NzIndexBuffer* vaoIndexBuffer = std::get<0>(key);
|
||||
|
||||
if (vaoIndexBuffer == indexBuffer)
|
||||
{
|
||||
// Suppression du VAO:
|
||||
// Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si
|
||||
// son contexte d'origine est actif, sinon il faudra le mettre en file d'attente
|
||||
// Ceci est géré par la méthode OpenGL::DeleteVertexArray
|
||||
|
||||
NzOpenGL::DeleteVertexArray(context, it->second.vao);
|
||||
vaos.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectType_VertexBuffer:
|
||||
{
|
||||
const NzVertexBuffer* vertexBuffer = static_cast<const NzVertexBuffer*>(object);
|
||||
for (auto& pair : s_vaos)
|
||||
{
|
||||
const NzContext* context = pair.first;
|
||||
VAO_Map& vaos = pair.second.vaoMap;
|
||||
|
||||
auto it = vaos.begin();
|
||||
while (it != vaos.end())
|
||||
{
|
||||
const VAO_Key& key = it->first;
|
||||
const NzVertexBuffer* vaoVertexBuffer = std::get<1>(key);
|
||||
|
||||
if (vaoVertexBuffer == vertexBuffer)
|
||||
{
|
||||
// Suppression du VAO:
|
||||
// Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si
|
||||
// son contexte d'origine est actif, sinon il faudra le mettre en file d'attente
|
||||
// Ceci est géré par la méthode OpenGL::DeleteVertexArray
|
||||
|
||||
NzOpenGL::DeleteVertexArray(context, it->second.vao);
|
||||
vaos.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectType_VertexDeclaration:
|
||||
{
|
||||
const NzVertexDeclaration* vertexDeclaration = static_cast<const NzVertexDeclaration*>(object);
|
||||
for (auto& pair : s_vaos)
|
||||
{
|
||||
const NzContext* context = pair.first;
|
||||
VAO_Map& vaos = pair.second.vaoMap;
|
||||
|
||||
auto it = vaos.begin();
|
||||
while (it != vaos.end())
|
||||
{
|
||||
const VAO_Key& key = it->first;
|
||||
const NzVertexDeclaration* vaoVertexDeclaration = std::get<2>(key);
|
||||
const NzVertexDeclaration* vaoInstancingDeclaration = std::get<3>(key);
|
||||
|
||||
if (vaoVertexDeclaration == vertexDeclaration || vaoInstancingDeclaration == vertexDeclaration)
|
||||
{
|
||||
// Suppression du VAO:
|
||||
// Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si
|
||||
// son contexte d'origine est actif, sinon il faudra le mettre en file d'attente
|
||||
// Ceci est géré par la méthode OpenGL::DeleteVertexArray
|
||||
|
||||
NzOpenGL::DeleteVertexArray(context, it->second.vao);
|
||||
vaos.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraInternalError("Unknown resource type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ObjectListener s_listener;
|
||||
}
|
||||
|
||||
void NzRenderer::BeginCondition(const NzGpuQuery& query, nzGpuQueryCondition condition)
|
||||
|
|
@ -1748,8 +1620,8 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
auto it = s_vaos.find(context);
|
||||
if (it == s_vaos.end())
|
||||
{
|
||||
Context_Entry entry(&s_listener, ObjectType_Context);
|
||||
entry.contextListener = context;
|
||||
Context_Entry entry;
|
||||
entry.onReleaseSlot = context->OnContextRelease.Connect(OnContextRelease);
|
||||
|
||||
it = s_vaos.insert(std::make_pair(context, std::move(entry))).first;
|
||||
}
|
||||
|
|
@ -1770,13 +1642,19 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
glBindVertexArray(s_currentVAO);
|
||||
|
||||
// On l'ajoute à notre liste
|
||||
VAO_Entry entry(&s_listener, ObjectType_IndexBuffer, ObjectType_VertexBuffer, ObjectType_VertexDeclaration, ObjectType_VertexDeclaration);
|
||||
entry.indexBufferListener = std::get<0>(key);
|
||||
entry.instancingDeclarationListener = std::get<3>(key);
|
||||
entry.vertexBufferListener = std::get<1>(key);
|
||||
entry.vertexDeclarationListener = std::get<2>(key);
|
||||
VAO_Entry entry;
|
||||
entry.vao = s_currentVAO;
|
||||
|
||||
// Connect the slots
|
||||
if (s_indexBuffer)
|
||||
entry.onIndexBufferReleaseSlot = s_indexBuffer->OnIndexBufferRelease.Connect(OnIndexBufferRelease);
|
||||
|
||||
if (instancingDeclaration)
|
||||
entry.onInstancingDeclarationReleaseSlot = instancingDeclaration->OnVertexDeclarationRelease.Connect(OnVertexDeclarationRelease);
|
||||
|
||||
entry.onVertexBufferReleaseSlot = s_vertexBuffer->OnVertexBufferRelease.Connect(OnVertexBufferRelease);
|
||||
entry.onVertexDeclarationReleaseSlot = vertexDeclaration->OnVertexDeclarationRelease.Connect(OnVertexDeclarationRelease);
|
||||
|
||||
vaoIt = vaoMap.insert(std::make_pair(key, std::move(entry))).first;
|
||||
|
||||
// Et on indique qu'on veut le programmer
|
||||
|
|
@ -1982,6 +1860,40 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
return true;
|
||||
}
|
||||
|
||||
void NzRenderer::OnContextRelease(const NzContext* context)
|
||||
{
|
||||
s_vaos.erase(context);
|
||||
}
|
||||
|
||||
void NzRenderer::OnIndexBufferRelease(const NzIndexBuffer* indexBuffer)
|
||||
{
|
||||
for (auto& pair : s_vaos)
|
||||
{
|
||||
const NzContext* context = pair.first;
|
||||
VAO_Map& vaos = pair.second.vaoMap;
|
||||
|
||||
auto it = vaos.begin();
|
||||
while (it != vaos.end())
|
||||
{
|
||||
const VAO_Key& key = it->first;
|
||||
const NzIndexBuffer* vaoIndexBuffer = std::get<0>(key);
|
||||
|
||||
if (vaoIndexBuffer == indexBuffer)
|
||||
{
|
||||
// Suppression du VAO:
|
||||
// Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si
|
||||
// son contexte d'origine est actif, sinon il faudra le mettre en file d'attente
|
||||
// Ceci est géré par la méthode OpenGL::DeleteVertexArray
|
||||
|
||||
NzOpenGL::DeleteVertexArray(context, it->second.vao);
|
||||
vaos.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NzRenderer::OnShaderReleased(const NzShader* shader)
|
||||
{
|
||||
if (s_shader == shader)
|
||||
|
|
@ -2002,6 +1914,65 @@ void NzRenderer::OnTextureReleased(const NzTexture* texture)
|
|||
}
|
||||
}
|
||||
|
||||
void NzRenderer::OnVertexBufferRelease(const NzVertexBuffer* vertexBuffer)
|
||||
{
|
||||
for (auto& pair : s_vaos)
|
||||
{
|
||||
const NzContext* context = pair.first;
|
||||
VAO_Map& vaos = pair.second.vaoMap;
|
||||
|
||||
auto it = vaos.begin();
|
||||
while (it != vaos.end())
|
||||
{
|
||||
const VAO_Key& key = it->first;
|
||||
const NzVertexBuffer* vaoVertexBuffer = std::get<1>(key);
|
||||
|
||||
if (vaoVertexBuffer == vertexBuffer)
|
||||
{
|
||||
// Suppression du VAO:
|
||||
// Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si
|
||||
// son contexte d'origine est actif, sinon il faudra le mettre en file d'attente
|
||||
// Ceci est géré par la méthode OpenGL::DeleteVertexArray
|
||||
|
||||
NzOpenGL::DeleteVertexArray(context, it->second.vao);
|
||||
vaos.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NzRenderer::OnVertexDeclarationRelease(const NzVertexDeclaration* vertexDeclaration)
|
||||
{
|
||||
for (auto& pair : s_vaos)
|
||||
{
|
||||
const NzContext* context = pair.first;
|
||||
VAO_Map& vaos = pair.second.vaoMap;
|
||||
|
||||
auto it = vaos.begin();
|
||||
while (it != vaos.end())
|
||||
{
|
||||
const VAO_Key& key = it->first;
|
||||
const NzVertexDeclaration* vaoVertexDeclaration = std::get<2>(key);
|
||||
const NzVertexDeclaration* vaoInstancingDeclaration = std::get<3>(key);
|
||||
|
||||
if (vaoVertexDeclaration == vertexDeclaration || vaoInstancingDeclaration == vertexDeclaration)
|
||||
{
|
||||
// Suppression du VAO:
|
||||
// Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si
|
||||
// son contexte d'origine est actif, sinon il faudra le mettre en file d'attente
|
||||
// Ceci est géré par la méthode OpenGL::DeleteVertexArray
|
||||
|
||||
NzOpenGL::DeleteVertexArray(context, it->second.vao);
|
||||
vaos.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NzRenderer::UpdateMatrix(nzMatrixType type)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
|
|
|
|||
|
|
@ -298,9 +298,9 @@ void NzFont::SetAtlas(const std::shared_ptr<NzAbstractAtlas>& atlas)
|
|||
m_atlas = atlas;
|
||||
if (m_atlas)
|
||||
{
|
||||
m_atlasClearedSlot = NazaraConnect(*m_atlas, OnAtlasCleared, OnAtlasCleared);
|
||||
m_atlasLayerChangeSlot = NazaraConnect(*m_atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
m_atlasReleaseSlot = NazaraConnect(*m_atlas, OnAtlasRelease, OnAtlasRelease);
|
||||
m_atlasClearedSlot = NazaraConnectThis(*m_atlas, OnAtlasCleared, OnAtlasCleared);
|
||||
m_atlasLayerChangeSlot = NazaraConnectThis(*m_atlas, OnAtlasLayerChange, OnAtlasLayerChange);
|
||||
m_atlasReleaseSlot = NazaraConnectThis(*m_atlas, OnAtlasRelease, OnAtlasRelease);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ m_startOffset(indexBuffer.m_startOffset)
|
|||
|
||||
NzIndexBuffer::~NzIndexBuffer()
|
||||
{
|
||||
NotifyDestroy();
|
||||
OnIndexBufferRelease(this);
|
||||
}
|
||||
|
||||
unsigned int NzIndexBuffer::ComputeCacheMissCount() const
|
||||
|
|
|
|||
|
|
@ -112,10 +112,10 @@ void NzSimpleTextDrawer::SetFont(NzFont* font)
|
|||
m_font = font;
|
||||
if (m_font)
|
||||
{
|
||||
m_atlasChangedSlot = NazaraConnect(*m_font, OnFontAtlasChanged, OnFontInvalidated);
|
||||
m_atlasLayerChangedSlot = NazaraConnect(*m_font, OnFontAtlasLayerChanged, OnFontInvalidated);
|
||||
m_fontReleaseSlot = NazaraConnect(*m_font, OnFontRelease, OnFontRelease);
|
||||
m_glyphCacheClearedSlot = NazaraConnect(*m_font, OnFontGlyphCacheCleared, OnFontInvalidated);
|
||||
m_atlasChangedSlot = NazaraConnectThis(*m_font, OnFontAtlasChanged, OnFontInvalidated);
|
||||
m_atlasLayerChangedSlot = NazaraConnectThis(*m_font, OnFontAtlasLayerChanged, OnFontInvalidated);
|
||||
m_fontReleaseSlot = NazaraConnectThis(*m_font, OnFontRelease, OnFontRelease);
|
||||
m_glyphCacheClearedSlot = NazaraConnectThis(*m_font, OnFontGlyphCacheCleared, OnFontInvalidated);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ m_vertexCount(vertexBuffer.m_vertexCount)
|
|||
|
||||
NzVertexBuffer::~NzVertexBuffer()
|
||||
{
|
||||
NotifyDestroy();
|
||||
OnVertexBufferRelease(this);
|
||||
}
|
||||
|
||||
bool NzVertexBuffer::Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ m_stride(declaration.m_stride)
|
|||
|
||||
NzVertexDeclaration::~NzVertexDeclaration()
|
||||
{
|
||||
NotifyDestroy();
|
||||
OnVertexDeclarationRelease(this);
|
||||
}
|
||||
|
||||
void NzVertexDeclaration::DisableComponent(nzVertexComponent component)
|
||||
|
|
|
|||
Loading…
Reference in New Issue