Added conditional rendering
Former-commit-id: 30c062a469ad5f534b95a33c07c92c89036aacf7
This commit is contained in:
@@ -923,6 +923,37 @@ bool NzOpenGL::Initialize()
|
||||
// AnisotropicFilter
|
||||
s_openGLextensions[nzOpenGLExtension_AnisotropicFilter] = IsSupported("GL_EXT_texture_filter_anisotropic");
|
||||
|
||||
// ConditionalRender
|
||||
if (s_openglVersion >= 300)
|
||||
{
|
||||
try
|
||||
{
|
||||
glBeginConditionalRender = reinterpret_cast<PFNGLBEGINCONDITIONALRENDERPROC>(LoadEntry("glBeginConditionalRender"));
|
||||
glEndConditionalRender = reinterpret_cast<PFNGLENDCONDITIONALRENDERPROC>(LoadEntry("glEndConditionalRender"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_ConditionalRender] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load Conditional Render: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_openGLextensions[nzOpenGLExtension_ConditionalRender] && IsSupported("GL_NV_conditional_render"))
|
||||
{
|
||||
try
|
||||
{
|
||||
glBeginConditionalRender = reinterpret_cast<PFNGLBEGINCONDITIONALRENDERPROC>(LoadEntry("glBeginConditionalRenderNV"));
|
||||
glEndConditionalRender = reinterpret_cast<PFNGLENDCONDITIONALRENDERPROC>(LoadEntry("glEndConditionalRenderNV"));
|
||||
|
||||
s_openGLextensions[nzOpenGLExtension_ConditionalRender] = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraWarning("Failed to load GL_NV_conditional_render: " + NzString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
// DebugOutput
|
||||
if (s_openglVersion >= 430 || IsSupported("GL_KHR_debug"))
|
||||
{
|
||||
@@ -1228,19 +1259,6 @@ void NzOpenGL::SetBuffer(nzBufferType type, GLuint id)
|
||||
s_contextStates->buffersBinding[type] = id;
|
||||
}
|
||||
|
||||
void NzOpenGL::SetScissorBox(const NzRecti& scissorBox)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!s_contextStates)
|
||||
{
|
||||
NazaraError("No context activated");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
s_contextStates->currentScissorBox = scissorBox;
|
||||
}
|
||||
|
||||
void NzOpenGL::SetProgram(GLuint id)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -1254,6 +1272,19 @@ void NzOpenGL::SetProgram(GLuint id)
|
||||
s_contextStates->currentProgram = id;
|
||||
}
|
||||
|
||||
void NzOpenGL::SetScissorBox(const NzRecti& scissorBox)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!s_contextStates)
|
||||
{
|
||||
NazaraError("No context activated");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
s_contextStates->currentScissorBox = scissorBox;
|
||||
}
|
||||
|
||||
void NzOpenGL::SetTarget(const NzRenderTarget* renderTarget)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -1855,6 +1886,16 @@ GLenum NzOpenGL::PrimitiveMode[nzPrimitiveMode_Max+1] =
|
||||
|
||||
static_assert(sizeof(NzOpenGL::PrimitiveMode)/sizeof(GLenum) == nzPrimitiveMode_Max+1, "Primitive mode array is incomplete");
|
||||
|
||||
GLenum NzOpenGL::QueryCondition[nzGpuQueryCondition_Max+1] =
|
||||
{
|
||||
GL_QUERY_WAIT, // nzGpuQueryCondition_NoWait
|
||||
GL_QUERY_BY_REGION_NO_WAIT, // nzGpuQueryCondition_Region_NoWait
|
||||
GL_QUERY_BY_REGION_WAIT, // nzGpuQueryCondition_Region_Wait
|
||||
GL_QUERY_WAIT // nzGpuQueryCondition_Wait
|
||||
};
|
||||
|
||||
static_assert(sizeof(NzOpenGL::QueryCondition)/sizeof(GLenum) == nzGpuQueryCondition_Max+1, "Query condition array is incomplete");
|
||||
|
||||
GLenum NzOpenGL::QueryMode[nzGpuQueryMode_Max+1] =
|
||||
{
|
||||
GL_ANY_SAMPLES_PASSED, // nzGpuQueryMode_AnySamplesPassed
|
||||
@@ -1963,6 +2004,7 @@ static_assert(sizeof(NzOpenGL::TextureTargetProxy)/sizeof(GLenum) == nzImageType
|
||||
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr;
|
||||
PFNGLATTACHSHADERPROC glAttachShader = nullptr;
|
||||
PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr;
|
||||
PFNGLBEGINQUERYPROC glBeginQuery = nullptr;
|
||||
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr;
|
||||
PFNGLBINDBUFFERPROC glBindBuffer = nullptr;
|
||||
@@ -2012,6 +2054,7 @@ PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced = nullptr;
|
||||
PFNGLDRAWTEXTURENVPROC glDrawTexture = nullptr;
|
||||
PFNGLENABLEPROC glEnable = nullptr;
|
||||
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = nullptr;
|
||||
PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender = nullptr;
|
||||
PFNGLENDQUERYPROC glEndQuery = nullptr;
|
||||
PFNGLFLUSHPROC glFlush = nullptr;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = nullptr;
|
||||
|
||||
@@ -184,6 +184,27 @@ namespace
|
||||
ResourceListener s_listener;
|
||||
}
|
||||
|
||||
void NzRenderer::BeginCondition(const NzGpuQuery& query, nzGpuQueryCondition condition)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (NzContext::GetCurrent() == nullptr)
|
||||
{
|
||||
NazaraError("No active context");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_ConditionalRendering])
|
||||
{
|
||||
NazaraError("Conditional rendering is not supported");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
glBeginConditionalRender(query.GetOpenGLID(), NzOpenGL::QueryCondition[condition]);
|
||||
}
|
||||
|
||||
void NzRenderer::Clear(nzUInt32 flags)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -463,6 +484,27 @@ void NzRenderer::Enable(nzRendererParameter parameter, bool enable)
|
||||
s_states.parameters[parameter] = enable;
|
||||
}
|
||||
|
||||
void NzRenderer::EndCondition()
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (NzContext::GetCurrent() == nullptr)
|
||||
{
|
||||
NazaraError("No active context");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!s_capabilities[nzRendererCap_ConditionalRendering])
|
||||
{
|
||||
NazaraError("Conditional rendering is not supported");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
glEndConditionalRender();
|
||||
}
|
||||
|
||||
void NzRenderer::Flush()
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -617,6 +659,7 @@ bool NzRenderer::Initialize()
|
||||
|
||||
// Récupération des capacités d'OpenGL
|
||||
s_capabilities[nzRendererCap_AnisotropicFilter] = NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter);
|
||||
s_capabilities[nzRendererCap_ConditionalRendering] = NzOpenGL::IsSupported(nzOpenGLExtension_ConditionalRender);
|
||||
s_capabilities[nzRendererCap_FP64] = NzOpenGL::IsSupported(nzOpenGLExtension_FP64);
|
||||
s_capabilities[nzRendererCap_HardwareBuffer] = true; // Natif depuis OpenGL 1.5
|
||||
s_capabilities[nzRendererCap_Instancing] = NzOpenGL::IsSupported(nzOpenGLExtension_DrawInstanced) && NzOpenGL::IsSupported(nzOpenGLExtension_InstancedArray);
|
||||
|
||||
Reference in New Issue
Block a user