From deb64d36fce8ba8364328cb907fb33193e870ce9 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Wed, 21 Aug 2013 21:01:32 +0000 Subject: [PATCH] Fix rendering artifacts with novbo=true gentangents=true glDrawRangeElements needs to know the range of vertexs that are used by the index array. With VBOs it doesn't really matter if the range is wrong (all the vertexes are in GPU memory anyway), but with CPU vertex arrays the driver has to memcpy the given range of data, so incorrect bounds will result in garbage data being rendered. With gentangents, the rendered mesh can have more vertexes than the original CModelDef, but was rendered with the CModelDef's vertex count. Use the correct vertex count instead. Refs #2050. This was SVN commit r13734. --- source/renderer/InstancingModelRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/InstancingModelRenderer.cpp b/source/renderer/InstancingModelRenderer.cpp index e96c3491d5..aa4c130c04 100644 --- a/source/renderer/InstancingModelRenderer.cpp +++ b/source/renderer/InstancingModelRenderer.cpp @@ -379,7 +379,7 @@ void InstancingModelRenderer::RenderModel(const CShaderProgramPtr& shader, int U #if CONFIG2_GLES glDrawElements(GL_TRIANGLES, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, m->imodeldefIndexBase); #else - pglDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)mdldef->GetNumVertices()-1, + pglDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)m->imodeldef->m_Array.GetNumVertices()-1, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, m->imodeldefIndexBase); #endif }