From eaae31aec1017505c1f4ca3826dd51113813a198 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 7 Jul 2012 02:52:39 +0000 Subject: [PATCH] Fix 'Building a vbo with too many verticies' error. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4061 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/gl/gl_rsurf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index cd14065fb..05c1c0640 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -297,6 +297,7 @@ void GLBE_GenBatchVBOs(vbo_t **vbochain, batch_t *firstbatch, batch_t *stopbatch void GLBE_GenBrushModelVBO(model_t *mod) { unsigned int vcount; + unsigned int cvcount; batch_t *batch, *fbatch; @@ -312,16 +313,18 @@ void GLBE_GenBrushModelVBO(model_t *mod) for (fbatch = batch = mod->batches[sortid]; batch != NULL; batch = batch->next) { + for (i = 0, cvcount = 0; i < batch->maxmeshes; i++) + cvcount += batch->mesh[i]->numvertexes; + //firstmesh got reused as the number of verticies in each batch - if (vcount + batch->firstmesh > MAX_INDICIES) + if (vcount + cvcount > MAX_INDICIES) { GLBE_GenBatchVBOs(&mod->vbos, fbatch, batch); fbatch = batch; vcount = 0; } - for (i = 0; i < batch->maxmeshes; i++) - vcount += batch->mesh[i]->numvertexes; + vcount += cvcount; } GLBE_GenBatchVBOs(&mod->vbos, fbatch, batch);