- 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/system/gl_cvars.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
@ -336,6 +337,8 @@ void GLWall::DrawDecal(DBaseDecal *decal)
else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); else gl_RenderState.AlphaFunc(GL_GREATER, 0.f);
gl_RenderState.Apply(); gl_RenderState.Apply();
if (!gl_usevbo)
{
glBegin(GL_TRIANGLE_FAN); glBegin(GL_TRIANGLE_FAN);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -343,6 +346,19 @@ void GLWall::DrawDecal(DBaseDecal *decal)
glVertex3f(dv[i].x, dv[i].z, dv[i].y); glVertex3f(dv[i].x, dv[i].z, dv[i].y);
} }
glEnd(); 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);
}
rendered_decals++; rendered_decals++;
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_MODULATE);
gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.SetObjectColor(0xffffffff);