From e6f14b055a6b10aaea80a952d79b9ec2ee91a621 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jun 2014 20:28:23 +0200 Subject: [PATCH] - use buffer based rendering for dynamic light pass and horizon portals. --- src/gl/scene/gl_flats.cpp | 10 ++--- src/gl/scene/gl_portal.cpp | 77 +++++++++++++++------------------- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/system/gl_cvars.h | 4 -- 4 files changed, 38 insertions(+), 55 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6b34fb659..56d2bd8d6 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -152,7 +152,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) gl_RenderState.Apply(); // Render the light - glBegin(GL_TRIANGLE_FAN); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); for (k = 0, v = sub->firstline; k < sub->numlines; k++, v++) { vertex_t *vt = v->v1; @@ -160,12 +160,10 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) t1.Set(vt->fx, zc, vt->fy); Vector nearToVert = t1 - nearPt; - glTexCoord2f((nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); - - glVertex3f(vt->fx, zc, vt->fy); + ptr->Set(vt->fx, zc, vt->fy, (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f); + ptr++; } - - glEnd(); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); node = node->nextLight; } } diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 4e07fc1a8..a7400ec22 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -999,26 +999,21 @@ void GLHorizonPortal::DrawContents() float vy=FIXED2FLOAT(viewy); // Draw to some far away boundary + // This is not drawn as larher strips because it causes visual glitches. for(float x=-32768+vx; x<32768+vx; x+=4096) { for(float y=-32768+vy; y<32768+vy;y+=4096) { - glBegin(GL_TRIANGLE_FAN); - - glTexCoord2f(x/64, -y/64); - glVertex3f(x, z, y); - - glTexCoord2f(x/64 + 64, -y/64); - glVertex3f(x + 4096, z, y); - - glTexCoord2f(x/64 + 64, -y/64 - 64); - glVertex3f(x + 4096, z, y + 4096); - - glTexCoord2f(x/64, -y/64 - 64); - glVertex3f(x, z, y + 4096); - - glEnd(); - + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, z, y, x / 64, -y / 64); + ptr++; + ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64); + ptr++; + ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64); + ptr++; + ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } @@ -1029,34 +1024,28 @@ void GLHorizonPortal::DrawContents() // Since I can't draw into infinity there can always be a // small gap - glBegin(GL_TRIANGLE_STRIP); - - glTexCoord2f(512.f, 0); - glVertex3f(-32768+vx, z, -32768+vy); - glTexCoord2f(512.f, tz); - glVertex3f(-32768+vx, vz, -32768+vy); - - glTexCoord2f(-512.f, 0); - glVertex3f(-32768+vx, z, 32768+vy); - glTexCoord2f(-512.f, tz); - glVertex3f(-32768+vx, vz, 32768+vy); - - glTexCoord2f(512.f, 0); - glVertex3f( 32768+vx, z, 32768+vy); - glTexCoord2f(512.f, tz); - glVertex3f( 32768+vx, vz, 32768+vy); - - glTexCoord2f(-512.f, 0); - glVertex3f( 32768+vx, z, -32768+vy); - glTexCoord2f(-512.f, tz); - glVertex3f( 32768+vx, vz, -32768+vy); - - glTexCoord2f(512.f, 0); - glVertex3f(-32768+vx, z, -32768+vy); - glTexCoord2f(512.f, tz); - glVertex3f(-32768+vx, vz, -32768+vy); - - glEnd(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); if (pushed) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 7648625d3..2879ade62 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -331,7 +331,7 @@ void GLWall::RenderFogBoundary() // this case is special because it needs to change the color in the middle of the polygon so it cannot use the standard function // This also needs no splits so it's relatively simple. gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_FAN); + glBegin(GL_TRIANGLE_FAN); // only used on GL 2.x! glVertex3f(glseg.x1, zbottom[0], glseg.y1); glVertex3f(glseg.x1, ztop[0], glseg.y1); glColor4fv(fc); diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h index 79321f5b5..d0e18bca4 100644 --- a/src/gl/system/gl_cvars.h +++ b/src/gl/system/gl_cvars.h @@ -43,8 +43,4 @@ EXTERN_CVAR(Bool, gl_dynlight_shader) EXTERN_CVAR(Float, gl_mask_threshold) EXTERN_CVAR(Float, gl_mask_sprite_threshold) -EXTERN_CVAR(Int, gl_usevbo) - - - #endif // _GL_INTERN_H