Fixed some Renderer bugs

Former-commit-id: 5a9a4be7282c4b43c47056064d344d41c42cbaba
This commit is contained in:
Lynix 2013-06-09 11:31:00 +02:00
parent 8897531618
commit 7080719287
1 changed files with 48 additions and 51 deletions

View File

@ -980,7 +980,7 @@ void NzRenderer::SetFaceFilling(nzFaceFilling fillingMode)
void NzRenderer::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
{
#if NAZARA_RENDERER_SAFE
if (indexBuffer && !indexBuffer->IsHardware() && !indexBuffer->IsSequential())
if (indexBuffer && !indexBuffer->IsSequential() && !indexBuffer->IsHardware())
{
NazaraError("Buffer must be hardware");
return;
@ -1423,8 +1423,6 @@ void NzRenderer::EnableInstancing(bool instancing)
}
bool NzRenderer::EnsureStateUpdate()
{
if (s_updateFlags != Update_None)
{
#ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr)
@ -1434,10 +1432,6 @@ bool NzRenderer::EnsureStateUpdate()
}
#endif
NzAbstractShader* shaderImpl;
if (s_updateFlags & Update_Shader)
{
#if NAZARA_RENDERER_SAFE
if (!s_shader)
{
@ -1446,11 +1440,12 @@ bool NzRenderer::EnsureStateUpdate()
}
#endif
// Il est plus rapide d'opérer sur l'implémentation du shader directement
shaderImpl = s_shader->m_impl;
NzAbstractShader* shaderImpl = s_shader->m_impl;
shaderImpl->Bind();
shaderImpl->BindTextures();
// Si le shader a été changé depuis la dernière fois
if (s_updateFlags & Update_Shader)
{
// Récupération des indices des variables uniformes (-1 si la variable n'existe pas)
s_matrixLocation[nzMatrixType_Projection] = shaderImpl->GetUniformLocation(nzShaderUniform_ProjMatrix);
s_matrixLocation[nzMatrixType_View] = shaderImpl->GetUniformLocation(nzShaderUniform_ViewMatrix);
@ -1472,9 +1467,11 @@ bool NzRenderer::EnsureStateUpdate()
s_updateFlags &= ~Update_Shader;
}
else
shaderImpl = s_shader->m_impl;
shaderImpl->BindTextures();
if (s_updateFlags != Update_None)
{
if (s_updateFlags & Update_Textures)
{
if (s_useSamplerObjects)
@ -1670,7 +1667,7 @@ bool NzRenderer::EnsureStateUpdate()
glDisableVertexAttribArray(NzOpenGL::AttributeIndex[nzElementUsage_TexCoord]+i);
}
if (s_indexBuffer)
if (s_indexBuffer && !s_indexBuffer->IsSequential())
{
NzHardwareBuffer* indexBufferImpl = static_cast<NzHardwareBuffer*>(s_indexBuffer->GetBuffer()->GetImpl());
indexBufferImpl->Bind();