From 394b0e442361a3ce6ae442c3b4e21c52c1f59bf4 Mon Sep 17 00:00:00 2001 From: plagman Date: Sat, 31 May 2008 08:29:40 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@751 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/include/polymer.h | 2 +- polymer/build/src/polymer.c | 48 ++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/polymer/build/include/polymer.h b/polymer/build/include/polymer.h index d4c9b387d..0a004e875 100644 --- a/polymer/build/include/polymer.h +++ b/polymer/build/include/polymer.h @@ -1,7 +1,6 @@ // here lies the GREAT JUSTICE RENDERER // TODO : // - CORE STUFF -// o use BufferData only once for VBOs // o there's also the texture alignment problem Hunter reported (san andreas fault) // o also sliding doors are still fucked up sometimes (like under the bar in E1L2) // o port glowmaps and detail maps from hacked polymost (:( @@ -65,6 +64,7 @@ typedef struct s_prsector { _prplane ceil; short curindice; int indicescount; + int oldindicescount; // stuff float wallsproffset; float floorsproffset; diff --git a/polymer/build/src/polymer.c b/polymer/build/src/polymer.c index ac87bd798..9ce915096 100644 --- a/polymer/build/src/polymer.c +++ b/polymer/build/src/polymer.c @@ -10,7 +10,7 @@ int pr_fov = 426; // appears to be the classic setting. int pr_billboardingmode = 1; int pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood int pr_wireframe = 0; -int pr_vbos = 0; +int pr_vbos = 1; int pr_mirrordepth = 1; int glerror; @@ -992,6 +992,14 @@ static int polymer_initsector(short sectnum) bglGenBuffersARB(1, &s->floor.ivbo); bglGenBuffersARB(1, &s->ceil.ivbo); + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->floor.vbo); + bglBufferDataARB(GL_ARRAY_BUFFER_ARB, sec->wallnum * sizeof(GLfloat) * 5, NULL, mapvbousage); + + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->ceil.vbo); + bglBufferDataARB(GL_ARRAY_BUFFER_ARB, sec->wallnum * sizeof(GLfloat) * 5, NULL, mapvbousage); + + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + s->controlstate = 2; // let updatesector know that everything needs to go prsectors[sectnum] = s; @@ -1181,9 +1189,9 @@ attributes: if ((pr_vbos > 0) && ((i == -1) || (wallinvalidate))) { bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->floor.vbo); - bglBufferDataARB(GL_ARRAY_BUFFER_ARB, sec->wallnum * sizeof(GLfloat) * 5, s->floor.buffer, mapvbousage); + bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sec->wallnum * sizeof(GLfloat) * 5, s->floor.buffer); bglBindBufferARB(GL_ARRAY_BUFFER_ARB, s->ceil.vbo); - bglBufferDataARB(GL_ARRAY_BUFFER_ARB, sec->wallnum * sizeof(GLfloat) * 5, s->ceil.buffer, mapvbousage); + bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sec->wallnum * sizeof(GLfloat) * 5, s->ceil.buffer); bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } @@ -1257,10 +1265,18 @@ finish: { polymer_buildfloor(sectnum); if ((pr_vbos > 0)) { + if (s->oldindicescount < s->indicescount) + { + bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->floor.ivbo); + bglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->indicescount * sizeof(GLushort), NULL, mapvbousage); + bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->ceil.ivbo); + bglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->indicescount * sizeof(GLushort), NULL, mapvbousage); + s->oldindicescount = s->indicescount; + } bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->floor.ivbo); - bglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->indicescount * sizeof(GLushort), s->floor.indices, mapvbousage); + bglBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, s->indicescount * sizeof(GLushort), s->floor.indices); bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->ceil.ivbo); - bglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s->indicescount * sizeof(GLushort), s->ceil.indices, mapvbousage); + bglBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, s->indicescount * sizeof(GLushort), s->ceil.indices); bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } } @@ -1411,9 +1427,22 @@ static int polymer_initwall(short wallnum) bglGenBuffersARB(1, &w->wall.vbo); bglGenBuffersARB(1, &w->over.vbo); bglGenBuffersARB(1, &w->mask.vbo); - bglGenBuffersARB(1, &w->stuffvbo); + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->wall.vbo); + bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, NULL, mapvbousage); + + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->over.vbo); + bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, NULL, mapvbousage); + + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->mask.vbo); + bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, NULL, mapvbousage); + + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo); + bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 8 * sizeof(GLfloat) * 3, NULL, mapvbousage); + + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + w->controlstate = 2; prwalls[wallnum] = w; @@ -1874,13 +1903,12 @@ static void polymer_updatewall(short wallnum) if ((pr_vbos > 0)) { bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->wall.vbo); - bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, w->wall.buffer, mapvbousage); + bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat) * 5, w->wall.buffer); bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->over.vbo); - bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, w->over.buffer, mapvbousage); + bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat) * 5, w->over.buffer); bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->mask.vbo); - bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 5, w->mask.buffer, mapvbousage); + bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat) * 5, w->mask.buffer); bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo); - bglBufferDataARB(GL_ARRAY_BUFFER_ARB, 8 * sizeof(GLfloat) * 3, NULL, mapvbousage); bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 4 * sizeof(GLfloat) * 3, w->bigportal); bglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 4 * sizeof(GLfloat) * 3, 4 * sizeof(GLfloat) * 3, w->cap); bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);