2013-06-23 07:49:34 +00:00
|
|
|
#ifndef __GL_DRAWINFO_H
|
|
|
|
#define __GL_DRAWINFO_H
|
|
|
|
|
|
|
|
#include "gl/scene/gl_wall.h"
|
|
|
|
|
|
|
|
enum GLDrawItemType
|
|
|
|
{
|
|
|
|
GLDIT_WALL,
|
|
|
|
GLDIT_FLAT,
|
|
|
|
GLDIT_SPRITE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DrawListType
|
|
|
|
{
|
2014-08-30 11:04:41 +00:00
|
|
|
GLDL_PLAINWALLS,
|
|
|
|
GLDL_PLAINFLATS,
|
|
|
|
GLDL_MASKEDWALLS,
|
|
|
|
GLDL_MASKEDFLATS,
|
|
|
|
GLDL_MASKEDWALLSOFS,
|
2014-07-15 19:16:59 +00:00
|
|
|
GLDL_MODELS,
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
GLDL_TRANSLUCENT,
|
|
|
|
GLDL_TRANSLUCENTBORDER,
|
|
|
|
|
|
|
|
GLDL_TYPES,
|
|
|
|
};
|
|
|
|
|
2016-04-27 21:19:54 +00:00
|
|
|
// more lists for handling of dynamic lights
|
|
|
|
enum DLDrawListType
|
|
|
|
{
|
|
|
|
// These are organized so that the various multipass rendering modes have to be set as few times as possible
|
|
|
|
GLLDL_WALLS_PLAIN, // dynamic lights on normal walls
|
|
|
|
GLLDL_WALLS_MASKED, // dynamic lights on masked midtextures
|
|
|
|
|
|
|
|
GLLDL_FLATS_PLAIN, // dynamic lights on normal flats
|
|
|
|
GLLDL_FLATS_MASKED, // dynamic lights on masked flats
|
|
|
|
|
|
|
|
GLLDL_WALLS_FOG, // lights on fogged walls
|
|
|
|
GLLDL_WALLS_FOGMASKED, // lights on fogged masked midtextures
|
|
|
|
|
|
|
|
GLLDL_FLATS_FOG, // lights on fogged walls
|
|
|
|
GLLDL_FLATS_FOGMASKED, // lights on fogged masked midtextures
|
|
|
|
|
|
|
|
GLLDL_TYPES,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
enum Drawpasses
|
|
|
|
{
|
2014-07-15 18:49:21 +00:00
|
|
|
GLPASS_ALL, // Main pass with dynamic lights
|
2014-08-19 12:18:21 +00:00
|
|
|
GLPASS_LIGHTSONLY, // only collect dynamic lights
|
|
|
|
GLPASS_PLAIN, // Main pass without dynamic lights
|
2013-06-23 07:49:34 +00:00
|
|
|
GLPASS_DECALS, // Draws a decal
|
|
|
|
GLPASS_TRANSLUCENT, // Draws translucent objects
|
2016-04-27 21:19:54 +00:00
|
|
|
|
|
|
|
// these are only used with texture based dynamic lights
|
|
|
|
GLPASS_BASE, // untextured base for dynamic lights
|
2016-04-27 22:58:44 +00:00
|
|
|
GLPASS_BASE_MASKED, // same but with active texture
|
2016-04-27 21:19:54 +00:00
|
|
|
GLPASS_LIGHTTEX, // lighttexture pass
|
2016-04-27 22:58:44 +00:00
|
|
|
GLPASS_TEXONLY, // finishing texture pass
|
|
|
|
GLPASS_LIGHTTEX_ADDITIVE, // lighttexture pass (additive)
|
2016-05-05 10:18:09 +00:00
|
|
|
GLPASS_LIGHTTEX_FOGGY, // lighttexture pass on foggy surfaces (forces all lights to be additive)
|
2016-04-27 21:19:54 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Intermediate struct to link one draw item into a draw list
|
|
|
|
//
|
|
|
|
// unfortunately this struct must not contain pointers because
|
|
|
|
// the arrays may be reallocated!
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
struct GLDrawItem
|
|
|
|
{
|
|
|
|
GLDrawItemType rendertype;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
GLDrawItem(GLDrawItemType _rendertype,int _index) : rendertype(_rendertype),index(_index) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SortNode
|
|
|
|
{
|
|
|
|
int itemindex;
|
|
|
|
SortNode * parent;
|
|
|
|
SortNode * next; // unsorted successor
|
|
|
|
SortNode * left; // left side of this node
|
|
|
|
SortNode * equal; // equal to this node
|
|
|
|
SortNode * right; // right side of this node
|
|
|
|
|
|
|
|
|
|
|
|
void UnlinkFromChain();
|
|
|
|
void Link(SortNode * hook);
|
|
|
|
void AddToEqual(SortNode * newnode);
|
|
|
|
void AddToLeft (SortNode * newnode);
|
|
|
|
void AddToRight(SortNode * newnode);
|
|
|
|
};
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// One draw list. This contains all info for one type of rendering data
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
struct GLDrawList
|
|
|
|
{
|
|
|
|
//private:
|
2018-04-15 12:24:43 +00:00
|
|
|
TArray<GLWall*> walls;
|
2013-06-23 07:49:34 +00:00
|
|
|
TArray<GLFlat> flats;
|
|
|
|
TArray<GLSprite> sprites;
|
|
|
|
TArray<GLDrawItem> drawitems;
|
|
|
|
int SortNodeStart;
|
|
|
|
SortNode * sorted;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GLDrawList()
|
|
|
|
{
|
|
|
|
next=NULL;
|
|
|
|
SortNodeStart=-1;
|
|
|
|
sorted=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
~GLDrawList()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
2014-07-15 19:16:59 +00:00
|
|
|
unsigned int Size()
|
|
|
|
{
|
|
|
|
return drawitems.Size();
|
|
|
|
}
|
|
|
|
|
2018-04-15 12:24:43 +00:00
|
|
|
GLWall *NewWall();
|
|
|
|
//void AddWall(GLWall * wall);
|
2013-06-23 07:49:34 +00:00
|
|
|
void AddFlat(GLFlat * flat);
|
|
|
|
void AddSprite(GLSprite * sprite);
|
|
|
|
void Reset();
|
2014-08-30 11:04:41 +00:00
|
|
|
void SortWalls();
|
|
|
|
void SortFlats();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MakeSortList();
|
|
|
|
SortNode * FindSortPlane(SortNode * head);
|
|
|
|
SortNode * FindSortWall(SortNode * head);
|
|
|
|
void SortPlaneIntoPlane(SortNode * head,SortNode * sort);
|
|
|
|
void SortWallIntoPlane(SortNode * head,SortNode * sort);
|
|
|
|
void SortSpriteIntoPlane(SortNode * head,SortNode * sort);
|
|
|
|
void SortWallIntoWall(SortNode * head,SortNode * sort);
|
|
|
|
void SortSpriteIntoWall(SortNode * head,SortNode * sort);
|
|
|
|
int CompareSprites(SortNode * a,SortNode * b);
|
|
|
|
SortNode * SortSpriteList(SortNode * head);
|
|
|
|
SortNode * DoSort(SortNode * head);
|
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
void DoDraw(int pass, int index, bool trans);
|
2013-06-23 07:49:34 +00:00
|
|
|
void DoDrawSorted(SortNode * node);
|
|
|
|
void DrawSorted();
|
2014-11-09 11:10:33 +00:00
|
|
|
void Draw(int pass, bool trans = false);
|
2014-08-30 11:04:41 +00:00
|
|
|
void DrawWalls(int pass);
|
|
|
|
void DrawFlats(int pass);
|
2014-08-30 13:34:14 +00:00
|
|
|
void DrawDecals();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
GLDrawList * next;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// these are used to link faked planes due to missing textures to a sector
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
struct gl_subsectorrendernode
|
|
|
|
{
|
|
|
|
gl_subsectorrendernode * next;
|
|
|
|
subsector_t * sub;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct FDrawInfo
|
|
|
|
{
|
|
|
|
struct wallseg
|
|
|
|
{
|
|
|
|
float x1, y1, z1, x2, y2, z2;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool temporary;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct MissingTextureInfo
|
|
|
|
{
|
|
|
|
seg_t * seg;
|
|
|
|
subsector_t * sub;
|
2016-04-07 23:42:43 +00:00
|
|
|
float Planez;
|
|
|
|
float Planezfront;
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MissingSegInfo
|
|
|
|
{
|
|
|
|
seg_t * seg;
|
|
|
|
int MTI_Index; // tells us which MissingTextureInfo represents this seg.
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SubsectorHackInfo
|
|
|
|
{
|
|
|
|
subsector_t * sub;
|
2017-03-09 18:54:41 +00:00
|
|
|
uint8_t flags;
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
2017-03-12 20:57:39 +00:00
|
|
|
GLSceneDrawer *mDrawer;
|
|
|
|
|
2017-03-09 18:54:41 +00:00
|
|
|
TArray<uint8_t> sectorrenderflags;
|
|
|
|
TArray<uint8_t> ss_renderflags;
|
|
|
|
TArray<uint8_t> no_renderflags;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
TArray<MissingTextureInfo> MissingUpperTextures;
|
|
|
|
TArray<MissingTextureInfo> MissingLowerTextures;
|
|
|
|
|
|
|
|
TArray<MissingSegInfo> MissingUpperSegs;
|
|
|
|
TArray<MissingSegInfo> MissingLowerSegs;
|
|
|
|
|
|
|
|
TArray<SubsectorHackInfo> SubsectorHacks;
|
|
|
|
|
|
|
|
TArray<gl_subsectorrendernode*> otherfloorplanes;
|
|
|
|
TArray<gl_subsectorrendernode*> otherceilingplanes;
|
|
|
|
|
|
|
|
TArray<sector_t *> CeilingStacks;
|
|
|
|
TArray<sector_t *> FloorStacks;
|
|
|
|
|
|
|
|
TArray<subsector_t *> HandledSubsectors;
|
|
|
|
|
|
|
|
FDrawInfo * next;
|
|
|
|
GLDrawList drawlists[GLDL_TYPES];
|
2016-04-28 15:55:58 +00:00
|
|
|
GLDrawList *dldrawlists = NULL; // only gets allocated when needed.
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
FDrawInfo();
|
|
|
|
~FDrawInfo();
|
|
|
|
void ClearBuffers();
|
|
|
|
|
2018-04-14 18:20:43 +00:00
|
|
|
void AddWall(GLWall *wall);
|
|
|
|
bool PutWallCompat(GLWall *wall, int passflag); // Legacy GL only.
|
|
|
|
|
2016-04-07 23:42:43 +00:00
|
|
|
bool DoOneSectorUpper(subsector_t * subsec, float planez);
|
|
|
|
bool DoOneSectorLower(subsector_t * subsec, float planez);
|
|
|
|
bool DoFakeBridge(subsector_t * subsec, float planez);
|
|
|
|
bool DoFakeCeilingBridge(subsector_t * subsec, float planez);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
bool CheckAnchorFloor(subsector_t * sub);
|
|
|
|
bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor);
|
|
|
|
bool CheckAnchorCeiling(subsector_t * sub);
|
|
|
|
bool CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor);
|
|
|
|
void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor);
|
|
|
|
void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor);
|
|
|
|
|
2016-04-07 23:42:43 +00:00
|
|
|
void AddUpperMissingTexture(side_t * side, subsector_t *sub, float backheight);
|
|
|
|
void AddLowerMissingTexture(side_t * side, subsector_t *sub, float backheight);
|
2013-06-23 07:49:34 +00:00
|
|
|
void HandleMissingTextures();
|
|
|
|
void DrawUnhandledMissingTextures();
|
|
|
|
void AddHackedSubsector(subsector_t * sub);
|
|
|
|
void HandleHackedSubsectors();
|
|
|
|
void AddFloorStack(sector_t * sec);
|
|
|
|
void AddCeilingStack(sector_t * sec);
|
|
|
|
void ProcessSectorStacks();
|
|
|
|
|
|
|
|
void AddOtherFloorPlane(int sector, gl_subsectorrendernode * node);
|
|
|
|
void AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node);
|
|
|
|
|
|
|
|
void StartScene();
|
|
|
|
void SetupFloodStencil(wallseg * ws);
|
|
|
|
void ClearFloodStencil(wallseg * ws);
|
|
|
|
void DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling);
|
|
|
|
void FloodUpperGap(seg_t * seg);
|
|
|
|
void FloodLowerGap(seg_t * seg);
|
|
|
|
|
2017-03-12 20:57:39 +00:00
|
|
|
static void StartDrawInfo(GLSceneDrawer *drawer);
|
2013-06-23 07:49:34 +00:00
|
|
|
static void EndDrawInfo();
|
|
|
|
|
|
|
|
gl_subsectorrendernode * GetOtherFloorPlanes(unsigned int sector)
|
|
|
|
{
|
|
|
|
if (sector<otherfloorplanes.Size()) return otherfloorplanes[sector];
|
|
|
|
else return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gl_subsectorrendernode * GetOtherCeilingPlanes(unsigned int sector)
|
|
|
|
{
|
|
|
|
if (sector<otherceilingplanes.Size()) return otherceilingplanes[sector];
|
|
|
|
else return NULL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class FDrawInfoList
|
|
|
|
{
|
|
|
|
TDeletingArray<FDrawInfo *> mList;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
FDrawInfo *GetNew();
|
|
|
|
void Release(FDrawInfo *);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern FDrawInfo * gl_drawinfo;
|
|
|
|
|
2014-07-13 18:41:20 +00:00
|
|
|
void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture);
|
2013-06-23 07:49:34 +00:00
|
|
|
void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending);
|
|
|
|
|
|
|
|
#endif
|