Made Context/RenderTarget usage constant
Former-commit-id: 07a2655ea642664bc49ca335cf5147ebf9fb9f26
This commit is contained in:
parent
2f85b258e9
commit
cd48d70844
|
|
@ -26,13 +26,13 @@ class NAZARA_API NzContext : public NzResource
|
||||||
|
|
||||||
const NzContextParameters& GetParameters() const;
|
const NzContextParameters& GetParameters() const;
|
||||||
bool IsActive() const;
|
bool IsActive() const;
|
||||||
bool SetActive(bool active);
|
bool SetActive(bool active) const;
|
||||||
void SwapBuffers();
|
void SwapBuffers();
|
||||||
|
|
||||||
static bool EnsureContext();
|
static bool EnsureContext();
|
||||||
static NzContext* GetCurrent();
|
static const NzContext* GetCurrent();
|
||||||
static const NzContext* GetReference();
|
static const NzContext* GetReference();
|
||||||
static NzContext* GetThreadContext();
|
static const NzContext* GetThreadContext();
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ class NAZARA_API NzRenderTarget
|
||||||
virtual bool HasContext() const = 0;
|
virtual bool HasContext() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool Activate() = 0;
|
virtual bool Activate() const = 0;
|
||||||
virtual void Desactivate();
|
virtual void Desactivate() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAZARA_RENDERTARGET_HPP
|
#endif // NAZARA_RENDERTARGET_HPP
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ class NAZARA_API NzRenderTexture : public NzRenderTarget, NzResourceListener, Nz
|
||||||
static bool IsSupported();
|
static bool IsSupported();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Activate() override;
|
bool Activate() const override;
|
||||||
void Desactivate() override;
|
void Desactivate() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnResourceDestroy(const NzResource* resource, int index) override;
|
void OnResourceDestroy(const NzResource* resource, int index) override;
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||||
bool HasContext() const;
|
bool HasContext() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Activate() override;
|
bool Activate() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool OnWindowCreated() override;
|
bool OnWindowCreated() override;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class NAZARA_API NzRenderer
|
||||||
static unsigned int GetMaxTextureUnits();
|
static unsigned int GetMaxTextureUnits();
|
||||||
static float GetPointSize();
|
static float GetPointSize();
|
||||||
static const NzShader* GetShader();
|
static const NzShader* GetShader();
|
||||||
static NzRenderTarget* GetTarget();
|
static const NzRenderTarget* GetTarget();
|
||||||
static NzRectui GetViewport();
|
static NzRectui GetViewport();
|
||||||
|
|
||||||
static bool HasCapability(nzRendererCap capability);
|
static bool HasCapability(nzRendererCap capability);
|
||||||
|
|
@ -84,7 +84,7 @@ class NAZARA_API NzRenderer
|
||||||
static void SetStencilPassOperation(nzStencilOperation passOperation);
|
static void SetStencilPassOperation(nzStencilOperation passOperation);
|
||||||
static void SetStencilReferenceValue(unsigned int refValue);
|
static void SetStencilReferenceValue(unsigned int refValue);
|
||||||
static void SetStencilZFailOperation(nzStencilOperation zfailOperation);
|
static void SetStencilZFailOperation(nzStencilOperation zfailOperation);
|
||||||
static bool SetTarget(NzRenderTarget* target);
|
static bool SetTarget(const NzRenderTarget* target);
|
||||||
static void SetTexture(nzUInt8 unit, const NzTexture* texture);
|
static void SetTexture(nzUInt8 unit, const NzTexture* texture);
|
||||||
static void SetTextureSampler(nzUInt8 textureUnit, const NzTextureSampler& sampler);
|
static void SetTextureSampler(nzUInt8 textureUnit, const NzTextureSampler& sampler);
|
||||||
static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
NAZARA_THREADLOCAL NzContext* currentContext = nullptr;
|
NAZARA_THREADLOCAL const NzContext* currentContext = nullptr;
|
||||||
NAZARA_THREADLOCAL NzContext* threadContext = nullptr;
|
NAZARA_THREADLOCAL const NzContext* threadContext = nullptr;
|
||||||
|
|
||||||
std::vector<NzContext*> contexts;
|
std::vector<NzContext*> contexts;
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ bool NzContext::IsActive() const
|
||||||
return currentContext == this;
|
return currentContext == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzContext::SetActive(bool active)
|
bool NzContext::SetActive(bool active) const
|
||||||
{
|
{
|
||||||
#ifdef NAZARA_RENDERER_SAFE
|
#ifdef NAZARA_RENDERER_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
|
|
@ -300,7 +300,7 @@ bool NzContext::EnsureContext()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzContext* NzContext::GetCurrent()
|
const NzContext* NzContext::GetCurrent()
|
||||||
{
|
{
|
||||||
return currentContext;
|
return currentContext;
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +310,7 @@ const NzContext* NzContext::GetReference()
|
||||||
return s_reference;
|
return s_reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzContext* NzContext::GetThreadContext()
|
const NzContext* NzContext::GetThreadContext()
|
||||||
{
|
{
|
||||||
EnsureContext();
|
EnsureContext();
|
||||||
|
|
||||||
|
|
@ -320,7 +320,6 @@ NzContext* NzContext::GetThreadContext()
|
||||||
bool NzContext::Initialize()
|
bool NzContext::Initialize()
|
||||||
{
|
{
|
||||||
NzContextParameters parameters;
|
NzContextParameters parameters;
|
||||||
// parameters.compatibilityProfile = true;
|
|
||||||
parameters.shared = false; // Difficile de partager le contexte de référence avec lui-même
|
parameters.shared = false; // Difficile de partager le contexte de référence avec lui-même
|
||||||
|
|
||||||
s_reference = new NzContext;
|
s_reference = new NzContext;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ bool NzRenderTarget::SetActive(bool active)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzRenderTarget::Desactivate()
|
void NzRenderTarget::Desactivate() const
|
||||||
{
|
{
|
||||||
// Seuls les target sans contextes (ex: NzRenderTexture) nécessitent une désactivation
|
// Seuls les target sans contextes (ex: NzRenderTexture) nécessitent une désactivation
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,11 @@ struct NzRenderTextureImpl
|
||||||
{
|
{
|
||||||
GLuint fbo;
|
GLuint fbo;
|
||||||
std::vector<Attachment> attachements;
|
std::vector<Attachment> attachements;
|
||||||
std::vector<GLenum> drawBuffers;
|
mutable std::vector<GLenum> drawBuffers;
|
||||||
NzContext* context;
|
const NzContext* context;
|
||||||
bool checked = false;
|
bool checked = false;
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
bool drawBuffersUpdated = true;
|
mutable bool drawBuffersUpdated = true;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
};
|
};
|
||||||
|
|
@ -665,7 +665,7 @@ bool NzRenderTexture::IsSupported()
|
||||||
return NzRenderer::HasCapability(nzRendererCap_RenderTexture);
|
return NzRenderer::HasCapability(nzRendererCap_RenderTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzRenderTexture::Activate()
|
bool NzRenderTexture::Activate() const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_RENDERER_SAFE
|
||||||
if (NzContext::GetCurrent() != m_impl->context)
|
if (NzContext::GetCurrent() != m_impl->context)
|
||||||
|
|
@ -694,7 +694,7 @@ bool NzRenderTexture::Activate()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzRenderTexture::Desactivate()
|
void NzRenderTexture::Desactivate() const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_RENDERER_SAFE
|
||||||
if (NzContext::GetCurrent() != m_impl->context)
|
if (NzContext::GetCurrent() != m_impl->context)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ bool NzRenderWindow::CopyToImage(NzImage* image) const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NzContext* currentContext = NzContext::GetCurrent();
|
const NzContext* currentContext = NzContext::GetCurrent();
|
||||||
if (m_context != currentContext)
|
if (m_context != currentContext)
|
||||||
{
|
{
|
||||||
if (!m_context->SetActive(true))
|
if (!m_context->SetActive(true))
|
||||||
|
|
@ -112,7 +112,7 @@ bool NzRenderWindow::CopyToTexture(NzTexture* texture) const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NzContext* currentContext = NzContext::GetCurrent();
|
const NzContext* currentContext = NzContext::GetCurrent();
|
||||||
if (m_context != currentContext)
|
if (m_context != currentContext)
|
||||||
{
|
{
|
||||||
if (!m_context->SetActive(true))
|
if (!m_context->SetActive(true))
|
||||||
|
|
@ -258,7 +258,7 @@ bool NzRenderWindow::HasContext() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzRenderWindow::Activate()
|
bool NzRenderWindow::Activate() const
|
||||||
{
|
{
|
||||||
if (m_context->SetActive(true))
|
if (m_context->SetActive(true))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ namespace
|
||||||
nzUInt8 s_maxAnisotropyLevel;
|
nzUInt8 s_maxAnisotropyLevel;
|
||||||
nzUInt32 s_stencilMask;
|
nzUInt32 s_stencilMask;
|
||||||
const NzIndexBuffer* s_indexBuffer;
|
const NzIndexBuffer* s_indexBuffer;
|
||||||
NzRenderTarget* s_target;
|
const NzRenderTarget* s_target;
|
||||||
const NzShader* s_shader;
|
const NzShader* s_shader;
|
||||||
const NzVertexBuffer* s_vertexBuffer;
|
const NzVertexBuffer* s_vertexBuffer;
|
||||||
const NzVertexDeclaration* s_vertexDeclaration;
|
const NzVertexDeclaration* s_vertexDeclaration;
|
||||||
|
|
@ -479,7 +479,7 @@ const NzShader* NzRenderer::GetShader()
|
||||||
return s_shader;
|
return s_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzRenderTarget* NzRenderer::GetTarget()
|
const NzRenderTarget* NzRenderer::GetTarget()
|
||||||
{
|
{
|
||||||
return s_target;
|
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)
|
if (s_target == target)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue