mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- some refactoring of GLDrawList to remove implementation-specific parts from this class.
This commit is contained in:
parent
ec13b77717
commit
77b301612a
5 changed files with 232 additions and 220 deletions
|
@ -857,8 +857,8 @@ void GLSceneDrawer::RenderMultipassStuff()
|
||||||
gl_RenderState.EnableTexture(false);
|
gl_RenderState.EnableTexture(false);
|
||||||
gl_RenderState.EnableBrightmap(false);
|
gl_RenderState.EnableBrightmap(false);
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_PLAIN);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_PLAIN);
|
||||||
|
|
||||||
// Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show
|
// Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show
|
||||||
// This creates a blank surface that only fills the nontransparent parts of the texture
|
// This creates a blank surface that only fills the nontransparent parts of the texture
|
||||||
|
@ -866,18 +866,18 @@ void GLSceneDrawer::RenderMultipassStuff()
|
||||||
gl_RenderState.SetTextureMode(TM_MASK);
|
gl_RenderState.SetTextureMode(TM_MASK);
|
||||||
gl_RenderState.EnableBrightmap(true);
|
gl_RenderState.EnableBrightmap(true);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_PLAIN);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_PLAIN);
|
||||||
|
|
||||||
// Part 3: The base of fogged surfaces, including the texture
|
// Part 3: The base of fogged surfaces, including the texture
|
||||||
gl_RenderState.EnableBrightmap(false);
|
gl_RenderState.EnableBrightmap(false);
|
||||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(gl_drawinfo, GLPASS_PLAIN);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(gl_drawinfo, GLPASS_PLAIN);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(gl_drawinfo, GLPASS_PLAIN);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_PLAIN);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(gl_drawinfo, GLPASS_PLAIN);
|
||||||
|
|
||||||
// second pass: draw lights
|
// second pass: draw lights
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
|
@ -888,10 +888,10 @@ void GLSceneDrawer::RenderMultipassStuff()
|
||||||
gl_RenderState.BlendFunc(GL_ONE, GL_ONE);
|
gl_RenderState.BlendFunc(GL_ONE, GL_ONE);
|
||||||
glDepthFunc(GL_EQUAL);
|
glDepthFunc(GL_EQUAL);
|
||||||
if (level.lightmode == 8) gl_RenderState.SetSoftLightLevel(255);
|
if (level.lightmode == 8) gl_RenderState.SetSoftLightLevel(255);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX);
|
||||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||||
}
|
}
|
||||||
else gl_lights = false;
|
else gl_lights = false;
|
||||||
|
@ -903,11 +903,11 @@ void GLSceneDrawer::RenderMultipassStuff()
|
||||||
gl_RenderState.EnableFog(false);
|
gl_RenderState.EnableFog(false);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_TEXONLY);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_TEXONLY);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_TEXONLY);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_TEXONLY);
|
||||||
gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold);
|
gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_TEXONLY);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_TEXONLY);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_TEXONLY);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_TEXONLY);
|
||||||
|
|
||||||
// fourth pass: additive lights
|
// fourth pass: additive lights
|
||||||
gl_RenderState.EnableFog(true);
|
gl_RenderState.EnableFog(true);
|
||||||
|
@ -915,14 +915,14 @@ void GLSceneDrawer::RenderMultipassStuff()
|
||||||
glDepthFunc(GL_EQUAL);
|
glDepthFunc(GL_EQUAL);
|
||||||
if (gl_SetupLightTexture())
|
if (gl_SetupLightTexture())
|
||||||
{
|
{
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_FOGGY);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_FOGGY);
|
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_LIGHTTEX_FOGGY);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY);
|
||||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_FOGGY);
|
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY);
|
||||||
}
|
}
|
||||||
else gl_lights = false;
|
else gl_lights = false;
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort)
|
||||||
|
|
||||||
// Splitting is done in the shader with clip planes, if available.
|
// Splitting is done in the shader with clip planes, if available.
|
||||||
// The fallback here only really works for non-y-billboarded sprites.
|
// The fallback here only really works for non-y-billboarded sprites.
|
||||||
if (gl.flags & RFL_NO_CLIP_PLANES)
|
if (screen->hwcaps & RFL_NO_CLIP_PLANES)
|
||||||
{
|
{
|
||||||
float newtexv = ss->vt + ((ss->vb - ss->vt) / (ss->z2 - ss->z1))*(fh->z - ss->z1);
|
float newtexv = ss->vt + ((ss->vb - ss->vt) / (ss->z2 - ss->z1))*(fh->z - ss->z1);
|
||||||
|
|
||||||
|
@ -481,8 +481,6 @@ EXTERN_CVAR(Int, gl_billboard_mode)
|
||||||
EXTERN_CVAR(Bool, gl_billboard_faces_camera)
|
EXTERN_CVAR(Bool, gl_billboard_faces_camera)
|
||||||
EXTERN_CVAR(Bool, gl_billboard_particles)
|
EXTERN_CVAR(Bool, gl_billboard_particles)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline double CalcIntersectionVertex(GLSprite *s, GLWall * w2)
|
inline double CalcIntersectionVertex(GLSprite *s, GLWall * w2)
|
||||||
{
|
{
|
||||||
float ax = s->x1, ay = s->y1;
|
float ax = s->x1, ay = s->y1;
|
||||||
|
@ -492,8 +490,6 @@ inline double CalcIntersectionVertex(GLSprite *s, GLWall * w2)
|
||||||
return ((ay - cy)*(dx - cx) - (ax - cx)*(dy - cy)) / ((bx - ax)*(dy - cy) - (by - ay)*(dx - cx));
|
return ((ay - cy)*(dx - cx) - (ax - cx)*(dy - cy)) / ((bx - ax)*(dy - cy) - (by - ay)*(dx - cx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort)
|
void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort)
|
||||||
{
|
{
|
||||||
GLWall *wh= walls[drawitems[head->itemindex].index];
|
GLWall *wh= walls[drawitems[head->itemindex].index];
|
||||||
|
@ -696,177 +692,15 @@ SortNode * GLDrawList::DoSort(SortNode * head)
|
||||||
return sn;
|
return sn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
void GLDrawList::DoDraw(int pass, int i, bool trans)
|
void GLDrawList::Sort()
|
||||||
{
|
{
|
||||||
switch(drawitems[i].rendertype)
|
MakeSortList();
|
||||||
{
|
sorted = DoSort(SortNodes[SortNodeStart]);
|
||||||
case GLDIT_FLAT:
|
|
||||||
{
|
|
||||||
GLFlat * f= flats[drawitems[i].index];
|
|
||||||
RenderFlat.Clock();
|
|
||||||
gl_drawinfo->DrawFlat(f, pass, trans);
|
|
||||||
RenderFlat.Unclock();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GLDIT_WALL:
|
|
||||||
{
|
|
||||||
GLWall * w= walls[drawitems[i].index];
|
|
||||||
RenderWall.Clock();
|
|
||||||
gl_drawinfo->DrawWall(w, pass);
|
|
||||||
RenderWall.Unclock();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GLDIT_SPRITE:
|
|
||||||
{
|
|
||||||
GLSprite * s= sprites[drawitems[i].index];
|
|
||||||
RenderSprite.Clock();
|
|
||||||
gl_drawinfo->DrawSprite(s, pass);
|
|
||||||
RenderSprite.Unclock();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
void GLDrawList::DoDrawSorted(SortNode * head)
|
|
||||||
{
|
|
||||||
float clipsplit[2];
|
|
||||||
int relation = 0;
|
|
||||||
float z = 0.f;
|
|
||||||
|
|
||||||
gl_RenderState.GetClipSplit(clipsplit);
|
|
||||||
|
|
||||||
if (drawitems[head->itemindex].rendertype == GLDIT_FLAT)
|
|
||||||
{
|
|
||||||
z = flats[drawitems[head->itemindex].index]->z;
|
|
||||||
relation = z > r_viewpoint.Pos.Z ? 1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// left is further away, i.e. for stuff above viewz its z coordinate higher, for stuff below viewz its z coordinate is lower
|
|
||||||
if (head->left)
|
|
||||||
{
|
|
||||||
if (relation == -1)
|
|
||||||
{
|
|
||||||
gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane
|
|
||||||
}
|
|
||||||
else if (relation == 1)
|
|
||||||
{
|
|
||||||
gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane
|
|
||||||
}
|
|
||||||
DoDrawSorted(head->left);
|
|
||||||
gl_RenderState.SetClipSplit(clipsplit);
|
|
||||||
}
|
|
||||||
DoDraw(GLPASS_TRANSLUCENT, head->itemindex, true);
|
|
||||||
if (head->equal)
|
|
||||||
{
|
|
||||||
SortNode * ehead=head->equal;
|
|
||||||
while (ehead)
|
|
||||||
{
|
|
||||||
DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex, true);
|
|
||||||
ehead=ehead->equal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// right is closer, i.e. for stuff above viewz its z coordinate is lower, for stuff below viewz its z coordinate is higher
|
|
||||||
if (head->right)
|
|
||||||
{
|
|
||||||
if (relation == 1)
|
|
||||||
{
|
|
||||||
gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane
|
|
||||||
}
|
|
||||||
else if (relation == -1)
|
|
||||||
{
|
|
||||||
gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane
|
|
||||||
}
|
|
||||||
DoDrawSorted(head->right);
|
|
||||||
gl_RenderState.SetClipSplit(clipsplit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
void GLDrawList::DrawSorted()
|
|
||||||
{
|
|
||||||
if (drawitems.Size()==0) return;
|
|
||||||
|
|
||||||
if (!sorted)
|
|
||||||
{
|
|
||||||
GLRenderer->mVBO->Map();
|
|
||||||
MakeSortList();
|
|
||||||
sorted=DoSort(SortNodes[SortNodeStart]);
|
|
||||||
GLRenderer->mVBO->Unmap();
|
|
||||||
}
|
|
||||||
gl_RenderState.ClearClipSplit();
|
|
||||||
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
|
||||||
{
|
|
||||||
glEnable(GL_CLIP_DISTANCE1);
|
|
||||||
glEnable(GL_CLIP_DISTANCE2);
|
|
||||||
}
|
|
||||||
DoDrawSorted(sorted);
|
|
||||||
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
|
||||||
{
|
|
||||||
glDisable(GL_CLIP_DISTANCE1);
|
|
||||||
glDisable(GL_CLIP_DISTANCE2);
|
|
||||||
}
|
|
||||||
gl_RenderState.ClearClipSplit();
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
void GLDrawList::Draw(int pass, bool trans)
|
|
||||||
{
|
|
||||||
for(unsigned i=0;i<drawitems.Size();i++)
|
|
||||||
{
|
|
||||||
DoDraw(pass, i, trans);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
void GLDrawList::DrawWalls(int pass)
|
|
||||||
{
|
|
||||||
RenderWall.Clock();
|
|
||||||
for(auto &item : drawitems)
|
|
||||||
{
|
|
||||||
gl_drawinfo->DrawWall(walls[item.index], pass);
|
|
||||||
}
|
|
||||||
RenderWall.Unclock();
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
void GLDrawList::DrawFlats(int pass)
|
|
||||||
{
|
|
||||||
RenderFlat.Clock();
|
|
||||||
for(unsigned i=0;i<drawitems.Size();i++)
|
|
||||||
{
|
|
||||||
gl_drawinfo->DrawFlat(flats[drawitems[i].index], pass, false);
|
|
||||||
}
|
|
||||||
RenderFlat.Unclock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -904,6 +738,7 @@ void GLDrawList::SortFlats()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -941,6 +776,178 @@ GLSprite *GLDrawList::NewSprite()
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
void GLDrawList::DoDraw(HWDrawInfo *di, int pass, int i, bool trans)
|
||||||
|
{
|
||||||
|
switch(drawitems[i].rendertype)
|
||||||
|
{
|
||||||
|
case GLDIT_FLAT:
|
||||||
|
{
|
||||||
|
GLFlat * f= flats[drawitems[i].index];
|
||||||
|
RenderFlat.Clock();
|
||||||
|
di->DrawFlat(f, pass, trans);
|
||||||
|
RenderFlat.Unclock();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLDIT_WALL:
|
||||||
|
{
|
||||||
|
GLWall * w= walls[drawitems[i].index];
|
||||||
|
RenderWall.Clock();
|
||||||
|
di->DrawWall(w, pass);
|
||||||
|
RenderWall.Unclock();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLDIT_SPRITE:
|
||||||
|
{
|
||||||
|
GLSprite * s= sprites[drawitems[i].index];
|
||||||
|
RenderSprite.Clock();
|
||||||
|
gl_drawinfo->DrawSprite(s, pass);
|
||||||
|
RenderSprite.Unclock();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
void GLDrawList::Draw(HWDrawInfo *di, int pass, bool trans)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < drawitems.Size(); i++)
|
||||||
|
{
|
||||||
|
DoDraw(di, pass, i, trans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
void GLDrawList::DrawWalls(HWDrawInfo *di, int pass)
|
||||||
|
{
|
||||||
|
RenderWall.Clock();
|
||||||
|
for (auto &item : drawitems)
|
||||||
|
{
|
||||||
|
di->DrawWall(walls[item.index], pass);
|
||||||
|
}
|
||||||
|
RenderWall.Unclock();
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
void GLDrawList::DrawFlats(HWDrawInfo *di, int pass)
|
||||||
|
{
|
||||||
|
RenderFlat.Clock();
|
||||||
|
for (unsigned i = 0; i<drawitems.Size(); i++)
|
||||||
|
{
|
||||||
|
di->DrawFlat(flats[drawitems[i].index], pass, false);
|
||||||
|
}
|
||||||
|
RenderFlat.Unclock();
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
void FDrawInfo::DoDrawSorted(GLDrawList *dl, SortNode * head)
|
||||||
|
{
|
||||||
|
float clipsplit[2];
|
||||||
|
int relation = 0;
|
||||||
|
float z = 0.f;
|
||||||
|
|
||||||
|
gl_RenderState.GetClipSplit(clipsplit);
|
||||||
|
|
||||||
|
if (dl->drawitems[head->itemindex].rendertype == GLDIT_FLAT)
|
||||||
|
{
|
||||||
|
z = dl->flats[dl->drawitems[head->itemindex].index]->z;
|
||||||
|
relation = z > r_viewpoint.Pos.Z ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// left is further away, i.e. for stuff above viewz its z coordinate higher, for stuff below viewz its z coordinate is lower
|
||||||
|
if (head->left)
|
||||||
|
{
|
||||||
|
if (relation == -1)
|
||||||
|
{
|
||||||
|
gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane
|
||||||
|
}
|
||||||
|
else if (relation == 1)
|
||||||
|
{
|
||||||
|
gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane
|
||||||
|
}
|
||||||
|
DoDrawSorted(dl, head->left);
|
||||||
|
gl_RenderState.SetClipSplit(clipsplit);
|
||||||
|
}
|
||||||
|
dl->DoDraw(gl_drawinfo, GLPASS_TRANSLUCENT, head->itemindex, true);
|
||||||
|
if (head->equal)
|
||||||
|
{
|
||||||
|
SortNode * ehead=head->equal;
|
||||||
|
while (ehead)
|
||||||
|
{
|
||||||
|
dl->DoDraw(gl_drawinfo, GLPASS_TRANSLUCENT, ehead->itemindex, true);
|
||||||
|
ehead=ehead->equal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// right is closer, i.e. for stuff above viewz its z coordinate is lower, for stuff below viewz its z coordinate is higher
|
||||||
|
if (head->right)
|
||||||
|
{
|
||||||
|
if (relation == 1)
|
||||||
|
{
|
||||||
|
gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane
|
||||||
|
}
|
||||||
|
else if (relation == -1)
|
||||||
|
{
|
||||||
|
gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane
|
||||||
|
}
|
||||||
|
DoDrawSorted(dl, head->right);
|
||||||
|
gl_RenderState.SetClipSplit(clipsplit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
void FDrawInfo::DrawSorted(int listindex)
|
||||||
|
{
|
||||||
|
GLDrawList *dl = &drawlists[listindex];
|
||||||
|
if (dl->drawitems.Size()==0) return;
|
||||||
|
|
||||||
|
if (!dl->sorted)
|
||||||
|
{
|
||||||
|
GLRenderer->mVBO->Map();
|
||||||
|
dl->Sort();
|
||||||
|
GLRenderer->mVBO->Unmap();
|
||||||
|
}
|
||||||
|
gl_RenderState.ClearClipSplit();
|
||||||
|
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
glEnable(GL_CLIP_DISTANCE1);
|
||||||
|
glEnable(GL_CLIP_DISTANCE2);
|
||||||
|
}
|
||||||
|
DoDrawSorted(dl, dl->sorted);
|
||||||
|
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
glDisable(GL_CLIP_DISTANCE1);
|
||||||
|
glDisable(GL_CLIP_DISTANCE2);
|
||||||
|
}
|
||||||
|
gl_RenderState.ClearClipSplit();
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Try to reuse the lists as often as possible as they contain resources that
|
// Try to reuse the lists as often as possible as they contain resources that
|
||||||
|
|
|
@ -156,13 +156,12 @@ public:
|
||||||
int CompareSprites(SortNode * a,SortNode * b);
|
int CompareSprites(SortNode * a,SortNode * b);
|
||||||
SortNode * SortSpriteList(SortNode * head);
|
SortNode * SortSpriteList(SortNode * head);
|
||||||
SortNode * DoSort(SortNode * head);
|
SortNode * DoSort(SortNode * head);
|
||||||
|
void Sort();
|
||||||
void DoDraw(int pass, int index, bool trans);
|
|
||||||
void DoDrawSorted(SortNode * node);
|
void DoDraw(HWDrawInfo *di, int pass, int index, bool trans);
|
||||||
void DrawSorted();
|
void Draw(HWDrawInfo *di, int pass, bool trans = false);
|
||||||
void Draw(int pass, bool trans = false);
|
void DrawWalls(HWDrawInfo *di, int pass);
|
||||||
void DrawWalls(int pass);
|
void DrawFlats(HWDrawInfo *di, int pass);
|
||||||
void DrawFlats(int pass);
|
|
||||||
|
|
||||||
GLDrawList * next;
|
GLDrawList * next;
|
||||||
} ;
|
} ;
|
||||||
|
@ -215,10 +214,10 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
void RenderMirrorSurface(GLWall *wall);
|
void RenderMirrorSurface(GLWall *wall);
|
||||||
void RenderTranslucentWall(GLWall *wall);
|
void RenderTranslucentWall(GLWall *wall);
|
||||||
void RenderTexturedWall(GLWall *wall, int rflags);
|
void RenderTexturedWall(GLWall *wall, int rflags);
|
||||||
void DrawWall(GLWall *wall, int pass);
|
void DrawWall(GLWall *wall, int pass) override;
|
||||||
|
|
||||||
// Flat drawer
|
// Flat drawer
|
||||||
void DrawFlat(GLFlat *flat, int pass, bool trans); // trans only has meaning for GLPASS_LIGHTSONLY
|
void DrawFlat(GLFlat *flat, int pass, bool trans) override; // trans only has meaning for GLPASS_LIGHTSONLY
|
||||||
void DrawSkyboxSector(GLFlat *flat, int pass, bool processlights);
|
void DrawSkyboxSector(GLFlat *flat, int pass, bool processlights);
|
||||||
void DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool istrans);
|
void DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool istrans);
|
||||||
void ProcessLights(GLFlat *flat, bool istrans);
|
void ProcessLights(GLFlat *flat, bool istrans);
|
||||||
|
@ -227,7 +226,10 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
|
|
||||||
// Sprite drawer
|
// Sprite drawer
|
||||||
void DrawSprite(GLSprite *sprite, int pass);
|
void DrawSprite(GLSprite *sprite, int pass);
|
||||||
|
|
||||||
|
void DoDrawSorted(GLDrawList *dl, SortNode * head);
|
||||||
|
void DrawSorted(int listindex);
|
||||||
|
|
||||||
// These two may be moved to the API independent part of the renderer later.
|
// These two may be moved to the API independent part of the renderer later.
|
||||||
void ProcessLowerMinisegs(TArray<seg_t *> &lowersegs) override;
|
void ProcessLowerMinisegs(TArray<seg_t *> &lowersegs) override;
|
||||||
void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) override;
|
void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) override;
|
||||||
|
|
|
@ -310,14 +310,14 @@ void GLSceneDrawer::RenderScene(int recursion)
|
||||||
if (gl.lightmethod == LM_DEFERRED && haslights)
|
if (gl.lightmethod == LM_DEFERRED && haslights)
|
||||||
{
|
{
|
||||||
GLRenderer->mLights->Begin();
|
GLRenderer->mLights->Begin();
|
||||||
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY, true);
|
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(gl_drawinfo, GLPASS_LIGHTSONLY, true);
|
||||||
gl_drawinfo->drawlists[GLDL_MODELS].Draw(GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_MODELS].Draw(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
SetupWeaponLight();
|
SetupWeaponLight();
|
||||||
GLRenderer->mLights->Finish();
|
GLRenderer->mLights->Finish();
|
||||||
}
|
}
|
||||||
|
@ -348,8 +348,8 @@ void GLSceneDrawer::RenderScene(int recursion)
|
||||||
|
|
||||||
gl_RenderState.EnableTexture(gl_texture);
|
gl_RenderState.EnableTexture(gl_texture);
|
||||||
gl_RenderState.EnableBrightmap(true);
|
gl_RenderState.EnableBrightmap(true);
|
||||||
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(pass);
|
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(gl_drawinfo, pass);
|
||||||
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(pass);
|
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, pass);
|
||||||
|
|
||||||
|
|
||||||
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
|
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
|
||||||
|
@ -359,20 +359,20 @@ void GLSceneDrawer::RenderScene(int recursion)
|
||||||
gl_RenderState.SetTextureMode(TM_MASK);
|
gl_RenderState.SetTextureMode(TM_MASK);
|
||||||
}
|
}
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||||
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(pass);
|
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(gl_drawinfo, pass);
|
||||||
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(pass);
|
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, pass);
|
||||||
|
|
||||||
// Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use.
|
// Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use.
|
||||||
if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0)
|
if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0)
|
||||||
{
|
{
|
||||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(-1.0f, -128.0f);
|
glPolygonOffset(-1.0f, -128.0f);
|
||||||
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(pass);
|
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(gl_drawinfo, pass);
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(0, 0);
|
glPolygonOffset(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_drawinfo->drawlists[GLDL_MODELS].Draw(pass);
|
gl_drawinfo->drawlists[GLDL_MODELS].Draw(gl_drawinfo, pass);
|
||||||
|
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
@ -428,8 +428,8 @@ void GLSceneDrawer::RenderTranslucent()
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
gl_RenderState.EnableBrightmap(true);
|
gl_RenderState.EnableBrightmap(true);
|
||||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_TRANSLUCENT);
|
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(gl_drawinfo, GLPASS_TRANSLUCENT);
|
||||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].DrawSorted();
|
gl_drawinfo->DrawSorted(GLDL_TRANSLUCENT);
|
||||||
gl_RenderState.EnableBrightmap(false);
|
gl_RenderState.EnableBrightmap(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,9 @@ public:
|
||||||
void GetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * subsec, float *out);
|
void GetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * subsec, float *out);
|
||||||
void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
||||||
|
|
||||||
|
virtual void DrawWall(GLWall *wall, int pass) = 0;
|
||||||
|
virtual void DrawFlat(GLFlat *flat, int pass, bool trans) = 0;
|
||||||
|
virtual void DrawSprite(GLSprite *sprite, int pass) = 0;
|
||||||
|
|
||||||
virtual void FloodUpperGap(seg_t * seg) = 0;
|
virtual void FloodUpperGap(seg_t * seg) = 0;
|
||||||
virtual void FloodLowerGap(seg_t * seg) = 0;
|
virtual void FloodLowerGap(seg_t * seg) = 0;
|
||||||
|
|
Loading…
Reference in a new issue