mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- allow vertex creation for sprites in the setup pass.
Currently only used by legacy hardware.
This commit is contained in:
parent
d37cd63fda
commit
74ba142eae
5 changed files with 41 additions and 14 deletions
|
@ -40,7 +40,6 @@
|
|||
#include "hwrenderer/scene/hw_clipper.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
|
||||
class FDrawInfoList
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/models/gl_models.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
|
||||
extern uint32_t r_renderercaps;
|
||||
|
@ -250,18 +249,17 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
FVector3 v[4];
|
||||
gl_RenderState.SetNormal(0, 0, 0);
|
||||
|
||||
if (sprite->CalculateVertices(this, v, &vp.Pos))
|
||||
if ((gl.flags & RFL_BUFFER_STORAGE) && sprite->vertexindex == -1)
|
||||
{
|
||||
sprite->CreateVertices(this);
|
||||
}
|
||||
if (sprite->polyoffset)
|
||||
{
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(-1.0f, -128.0f);
|
||||
}
|
||||
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, v[0][0], v[0][1], v[0][2], sprite->ul, sprite->vt);
|
||||
qd.Set(1, v[1][0], v[1][1], v[1][2], sprite->ur, sprite->vt);
|
||||
qd.Set(2, v[2][0], v[2][1], v[2][2], sprite->ul, sprite->vb);
|
||||
qd.Set(3, v[3][0], v[3][1], v[3][2], sprite->ur, sprite->vb);
|
||||
qd.Render(GL_TRIANGLE_STRIP);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4);
|
||||
|
||||
if (foglayer)
|
||||
{
|
||||
|
@ -271,7 +269,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_RenderState.Apply();
|
||||
qd.Render(GL_TRIANGLE_STRIP);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4);
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ public:
|
|||
int translation;
|
||||
int index;
|
||||
int depth;
|
||||
int vertexindex;
|
||||
|
||||
float topclip;
|
||||
float bottomclip;
|
||||
|
@ -387,6 +388,7 @@ public:
|
|||
public:
|
||||
|
||||
GLSprite() {}
|
||||
void CreateVertices(HWDrawInfo *di);
|
||||
void PutSprite(HWDrawInfo *di, bool translucent);
|
||||
void Process(HWDrawInfo *di, AActor* thing,sector_t * sector, area_t in_area, int thruportal = false);
|
||||
void ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *sector);//, int shade, int fakeside)
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "hwrenderer/scene/hw_fakeflat.h"
|
||||
#include "hwrenderer/scene/hw_portal.h"
|
||||
#include "hwrenderer/data/flatvertices.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/utility/hw_clock.h"
|
||||
#include "hwrenderer/utility/hw_lighting.h"
|
||||
|
@ -228,10 +229,39 @@ inline void GLSprite::PutSprite(HWDrawInfo *di, bool translucent)
|
|||
else
|
||||
dynlightindex = -1;
|
||||
|
||||
|
||||
vertexindex = -1;
|
||||
if (!(screen->hwcaps & RFL_BUFFER_STORAGE))
|
||||
{
|
||||
CreateVertices(di);
|
||||
}
|
||||
di->AddSprite(this, translucent);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void GLSprite::CreateVertices(HWDrawInfo *di)
|
||||
{
|
||||
if (modelframe == nullptr)
|
||||
{
|
||||
FVector3 v[4];
|
||||
polyoffset = CalculateVertices(di, v, &di->Viewpoint.Pos);
|
||||
auto vert = di->AllocVertices(4);
|
||||
auto vp = vert.first;
|
||||
vertexindex = vert.second;
|
||||
|
||||
vp[0].Set(v[0][0], v[0][1], v[0][2], ul, vt);
|
||||
vp[1].Set(v[1][0], v[1][1], v[1][2], ur, vt);
|
||||
vp[2].Set(v[2][0], v[2][1], v[2][2], ul, vb);
|
||||
vp[3].Set(v[3][0], v[3][1], v[3][2], ur, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue