- add vertex buffer based rendering for decals.

This commit is contained in:
Christoph Oelckers 2014-05-12 22:46:30 +02:00
parent cf45f2d718
commit 579eff5b96
2 changed files with 23 additions and 7 deletions

View file

@ -45,6 +45,7 @@
#include "gl/system/gl_cvars.h"
#include "gl/data/gl_data.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h"
#include "gl/renderer/gl_renderstate.h"
@ -336,13 +337,28 @@ void GLWall::DrawDecal(DBaseDecal *decal)
else gl_RenderState.AlphaFunc(GL_GREATER, 0.f);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
for(i=0;i<4;i++)
if (!gl_usevbo)
{
glTexCoord2f(dv[i].u,dv[i].v);
glVertex3f(dv[i].x,dv[i].z,dv[i].y);
glBegin(GL_TRIANGLE_FAN);
for (i = 0; i < 4; i++)
{
glTexCoord2f(dv[i].u, dv[i].v);
glVertex3f(dv[i].x, dv[i].z, dv[i].y);
}
glEnd();
}
else
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
for (i = 0; i < 4; i++)
{
ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v);
ptr++;
}
unsigned int offset;
unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset);
glDrawArrays(GL_TRIANGLE_FAN, offset, count);
}
glEnd();
rendered_decals++;
gl_RenderState.SetTextureMode(TM_MODULATE);
gl_RenderState.SetObjectColor(0xffffffff);

View file

@ -153,14 +153,14 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass)
// Render the light
glBegin(GL_TRIANGLE_FAN);
for(k = 0, v = sub->firstline; k < sub->numlines; k++, v++)
for (k = 0, v = sub->firstline; k < sub->numlines; k++, v++)
{
vertex_t *vt = v->v1;
float zc = plane.plane.ZatPoint(vt->fx, vt->fy) + dz;
t1.Set(vt->fx, zc, vt->fy);
Vector nearToVert = t1 - nearPt;
glTexCoord2f( (nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f);
glTexCoord2f((nearToVert.Dot(right) * scale) + 0.5f, (nearToVert.Dot(up) * scale) + 0.5f);
glVertex3f(vt->fx, zc, vt->fy);
}