Made Context/RenderTarget usage constant
Former-commit-id: 07a2655ea642664bc49ca335cf5147ebf9fb9f26
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
NAZARA_THREADLOCAL NzContext* currentContext = nullptr;
|
||||
NAZARA_THREADLOCAL NzContext* threadContext = nullptr;
|
||||
NAZARA_THREADLOCAL const NzContext* currentContext = nullptr;
|
||||
NAZARA_THREADLOCAL const NzContext* threadContext = nullptr;
|
||||
|
||||
std::vector<NzContext*> contexts;
|
||||
|
||||
@@ -219,7 +219,7 @@ bool NzContext::IsActive() const
|
||||
return currentContext == this;
|
||||
}
|
||||
|
||||
bool NzContext::SetActive(bool active)
|
||||
bool NzContext::SetActive(bool active) const
|
||||
{
|
||||
#ifdef NAZARA_RENDERER_SAFE
|
||||
if (!m_impl)
|
||||
@@ -300,7 +300,7 @@ bool NzContext::EnsureContext()
|
||||
return true;
|
||||
}
|
||||
|
||||
NzContext* NzContext::GetCurrent()
|
||||
const NzContext* NzContext::GetCurrent()
|
||||
{
|
||||
return currentContext;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ const NzContext* NzContext::GetReference()
|
||||
return s_reference;
|
||||
}
|
||||
|
||||
NzContext* NzContext::GetThreadContext()
|
||||
const NzContext* NzContext::GetThreadContext()
|
||||
{
|
||||
EnsureContext();
|
||||
|
||||
@@ -320,7 +320,6 @@ NzContext* NzContext::GetThreadContext()
|
||||
bool NzContext::Initialize()
|
||||
{
|
||||
NzContextParameters parameters;
|
||||
// parameters.compatibilityProfile = true;
|
||||
parameters.shared = false; // Difficile de partager le contexte de référence avec lui-même
|
||||
|
||||
s_reference = new NzContext;
|
||||
|
||||
@@ -23,7 +23,7 @@ bool NzRenderTarget::SetActive(bool active)
|
||||
return true;
|
||||
}
|
||||
|
||||
void NzRenderTarget::Desactivate()
|
||||
void NzRenderTarget::Desactivate() const
|
||||
{
|
||||
// Seuls les target sans contextes (ex: NzRenderTexture) nécessitent une désactivation
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ struct NzRenderTextureImpl
|
||||
{
|
||||
GLuint fbo;
|
||||
std::vector<Attachment> attachements;
|
||||
std::vector<GLenum> drawBuffers;
|
||||
NzContext* context;
|
||||
mutable std::vector<GLenum> drawBuffers;
|
||||
const NzContext* context;
|
||||
bool checked = false;
|
||||
bool complete = false;
|
||||
bool drawBuffersUpdated = true;
|
||||
mutable bool drawBuffersUpdated = true;
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
};
|
||||
@@ -665,7 +665,7 @@ bool NzRenderTexture::IsSupported()
|
||||
return NzRenderer::HasCapability(nzRendererCap_RenderTexture);
|
||||
}
|
||||
|
||||
bool NzRenderTexture::Activate()
|
||||
bool NzRenderTexture::Activate() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (NzContext::GetCurrent() != m_impl->context)
|
||||
@@ -694,7 +694,7 @@ bool NzRenderTexture::Activate()
|
||||
return true;
|
||||
}
|
||||
|
||||
void NzRenderTexture::Desactivate()
|
||||
void NzRenderTexture::Desactivate() const
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (NzContext::GetCurrent() != m_impl->context)
|
||||
|
||||
@@ -59,7 +59,7 @@ bool NzRenderWindow::CopyToImage(NzImage* image) const
|
||||
}
|
||||
#endif
|
||||
|
||||
NzContext* currentContext = NzContext::GetCurrent();
|
||||
const NzContext* currentContext = NzContext::GetCurrent();
|
||||
if (m_context != currentContext)
|
||||
{
|
||||
if (!m_context->SetActive(true))
|
||||
@@ -112,7 +112,7 @@ bool NzRenderWindow::CopyToTexture(NzTexture* texture) const
|
||||
}
|
||||
#endif
|
||||
|
||||
NzContext* currentContext = NzContext::GetCurrent();
|
||||
const NzContext* currentContext = NzContext::GetCurrent();
|
||||
if (m_context != currentContext)
|
||||
{
|
||||
if (!m_context->SetActive(true))
|
||||
@@ -258,7 +258,7 @@ bool NzRenderWindow::HasContext() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzRenderWindow::Activate()
|
||||
bool NzRenderWindow::Activate() const
|
||||
{
|
||||
if (m_context->SetActive(true))
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace
|
||||
nzUInt8 s_maxAnisotropyLevel;
|
||||
nzUInt32 s_stencilMask;
|
||||
const NzIndexBuffer* s_indexBuffer;
|
||||
NzRenderTarget* s_target;
|
||||
const NzRenderTarget* s_target;
|
||||
const NzShader* s_shader;
|
||||
const NzVertexBuffer* s_vertexBuffer;
|
||||
const NzVertexDeclaration* s_vertexDeclaration;
|
||||
@@ -479,7 +479,7 @@ const NzShader* NzRenderer::GetShader()
|
||||
return s_shader;
|
||||
}
|
||||
|
||||
NzRenderTarget* NzRenderer::GetTarget()
|
||||
const NzRenderTarget* NzRenderer::GetTarget()
|
||||
{
|
||||
return s_target;
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ void NzRenderer::SetStencilZFailOperation(nzStencilOperation zfailOperation)
|
||||
}
|
||||
}
|
||||
|
||||
bool NzRenderer::SetTarget(NzRenderTarget* target)
|
||||
bool NzRenderer::SetTarget(const NzRenderTarget* target)
|
||||
{
|
||||
if (s_target == target)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user