Improved code based on CppCheck results

None of this should change the engine's behavior, but the code is better
this way.


Former-commit-id: 0127769848fc1f7fc8006ee607985cfc0ead2965
This commit is contained in:
Lynix
2015-06-05 13:25:17 +02:00
parent 0f27930467
commit fc65b30f84
15 changed files with 22 additions and 49 deletions

View File

@@ -1797,10 +1797,6 @@ bool NzRenderer::EnsureStateUpdate()
if (update)
{
const NzVertexDeclaration* vertexDeclaration;
unsigned int bufferOffset;
unsigned int stride;
// Pour éviter la duplication de code, on va utiliser une astuce via une boucle for
for (unsigned int i = 0; i < (s_instancing ? 2 : 1); ++i)
{
@@ -1810,9 +1806,9 @@ bool NzRenderer::EnsureStateUpdate()
NzHardwareBuffer* vertexBufferImpl = static_cast<NzHardwareBuffer*>(vertexBuffer->GetBuffer()->GetImpl());
glBindBuffer(NzOpenGL::BufferTarget[nzBufferType_Vertex], vertexBufferImpl->GetOpenGLID());
bufferOffset = vertexBuffer->GetStartOffset();
vertexDeclaration = vertexBuffer->GetVertexDeclaration();
stride = vertexDeclaration->GetStride();
unsigned int bufferOffset = vertexBuffer->GetStartOffset();
const NzVertexDeclaration* vertexDeclaration = vertexBuffer->GetVertexDeclaration();
unsigned int stride = vertexDeclaration->GetStride();
// On définit les bornes (une fois de plus selon l'itération)
unsigned int start = (i == 0) ? nzVertexComponent_FirstVertexData : nzVertexComponent_FirstInstanceData;