diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 24fe5b4d53..0a32abf6bf 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -26,6 +26,14 @@ struct FFlatVertex float u,v; // texture coordinates void SetFlatVertex(vertex_t *vt, const secplane_t &plane); + void Set(float xx, float zz, float yy, float uu, float vv) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + } }; #define VTO ((FFlatVertex*)NULL) diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 6ac50a785e..1945e8bf5a 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -528,7 +528,7 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) touching_subsectors = AddLightNode(&subSec->lighthead[additive], subSec, this, touching_subsectors); if (subSec->sector->validcount != ::validcount) { - touching_sector = AddLightNode(&subSec->sector->lighthead[additive], subSec->sector, this, touching_sector); + touching_sector = AddLightNode(&subSec->render_sector->lighthead[additive], subSec->sector, this, touching_sector); subSec->sector->validcount = ::validcount; } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 84ecbf0a1c..63c7bd46b3 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -52,6 +52,7 @@ #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" #include "gl/dynlights/gl_glow.h" #include "gl/scene/gl_drawinfo.h" @@ -60,6 +61,7 @@ #include "gl/shaders/gl_shader.h" #include "gl/textures/gl_material.h" #include "gl/utility/gl_clock.h" +#include "gl/data/gl_vertexbuffer.h" CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); @@ -265,33 +267,10 @@ void GLSprite::Draw(int pass) v4 = Vector(x2, z2, y2); } - glBegin(GL_TRIANGLE_STRIP); - if (gltexture) + FFlatVertex *ptr; + unsigned int offset, count; + if (!gl_usevbo) { - glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); - glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); - glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); - glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); - } - else // Particle - { - glVertex3fv(&v1[0]); - glVertex3fv(&v2[0]); - glVertex3fv(&v3[0]); - glVertex3fv(&v4[0]); - } - - glEnd(); - - if (foglayer) - { - // If we get here we know that we have colored fog and no fixed colormap. - gl_SetFog(foglevel, rel, &Colormap, additivefog); - gl_RenderState.SetFixedColormap(CM_FOGLAYER); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl_RenderState.Apply(); - glBegin(GL_TRIANGLE_STRIP); if (gltexture) { @@ -307,7 +286,56 @@ void GLSprite::Draw(int pass) glVertex3fv(&v3[0]); glVertex3fv(&v4[0]); } + glEnd(); + } + else + { + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(v1[0], v1[1], v1[2], ul, vt); + ptr++; + ptr->Set(v2[0], v2[1], v2[2], ur, vt); + ptr++; + ptr->Set(v3[0], v3[1], v3[2], ul, vb); + ptr++; + ptr->Set(v4[0], v4[1], v4[2], ur, vb); + ptr++; + count = GLRenderer->mVBO->GetCount(ptr, &offset); + glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + } + + if (foglayer) + { + // If we get here we know that we have colored fog and no fixed colormap. + gl_SetFog(foglevel, rel, &Colormap, additivefog); + gl_RenderState.SetFixedColormap(CM_FOGLAYER); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.Apply(); + + if (!gl_usevbo) + { + glBegin(GL_TRIANGLE_STRIP); + if (gltexture) + { + glTexCoord2f(ul, vt); glVertex3fv(&v1[0]); + glTexCoord2f(ur, vt); glVertex3fv(&v2[0]); + glTexCoord2f(ul, vb); glVertex3fv(&v3[0]); + glTexCoord2f(ur, vb); glVertex3fv(&v4[0]); + } + else // Particle + { + glVertex3fv(&v1[0]); + glVertex3fv(&v2[0]); + glVertex3fv(&v3[0]); + glVertex3fv(&v4[0]); + } + glEnd(); + } + else + { + glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + } gl_RenderState.SetFixedColormap(CM_DEFAULT); } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index dc7127690f..ca32e98a60 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -290,32 +290,16 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) { FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - ptr->x = glseg.x1; - ptr->y = glseg.y1; - ptr->z = zbottom[0]; - ptr->u = tcs[0].u; - ptr->v = tcs[0].v; + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); ptr++; if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); - ptr->x = glseg.x1; - ptr->y = glseg.y1; - ptr->z = ztop[0]; - ptr->u = tcs[1].u; - ptr->v = tcs[1].v; + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v); ptr++; if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); - ptr->x = glseg.x2; - ptr->y = glseg.y2; - ptr->z = ztop[1]; - ptr->u = tcs[2].u; - ptr->v = tcs[2].v; + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v); ptr++; if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); - ptr->x = glseg.x2; - ptr->y = glseg.y2; - ptr->z = zbottom[1]; - ptr->u = tcs[3].u; - ptr->v = tcs[3].v; + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); ptr++; if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); unsigned int offset;