2017-03-11 23:19:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "m_fixed.h"
|
|
|
|
#include "gl_clipper.h"
|
2017-03-12 11:03:54 +00:00
|
|
|
#include "gl_portal.h"
|
2017-03-12 20:57:39 +00:00
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
2017-03-12 22:13:07 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
2017-03-11 23:19:20 +00:00
|
|
|
|
|
|
|
class GLSceneDrawer
|
|
|
|
{
|
|
|
|
fixed_t viewx, viewy; // since the nodes are still fixed point, keeping the view position also fixed point for node traversal is faster.
|
|
|
|
|
|
|
|
subsector_t *currentsubsector; // used by the line processing code.
|
|
|
|
sector_t *currentsector;
|
2017-03-12 11:03:54 +00:00
|
|
|
|
2018-03-01 00:27:12 +00:00
|
|
|
TMap<DPSprite*, int> weapondynlightindex;
|
|
|
|
|
|
|
|
void SetupWeaponLight();
|
|
|
|
|
2017-03-12 11:03:54 +00:00
|
|
|
void RenderMultipassStuff();
|
2017-03-12 20:57:39 +00:00
|
|
|
|
2017-03-11 23:19:20 +00:00
|
|
|
void UnclipSubsector(subsector_t *sub);
|
|
|
|
void AddLine (seg_t *seg, bool portalclip);
|
|
|
|
void PolySubsector(subsector_t * sub);
|
|
|
|
void RenderPolyBSPNode (void *node);
|
|
|
|
void AddPolyobjs(subsector_t *sub);
|
|
|
|
void AddLines(subsector_t * sub, sector_t * sector);
|
|
|
|
void AddSpecialPortalLines(subsector_t * sub, sector_t * sector, line_t *line);
|
|
|
|
void RenderThings(subsector_t * sub, sector_t * sector);
|
|
|
|
void DoSubsector(subsector_t * sub);
|
|
|
|
void RenderBSPNode(void *node);
|
|
|
|
|
2017-03-12 11:03:54 +00:00
|
|
|
void RenderScene(int recursion);
|
|
|
|
void RenderTranslucent();
|
|
|
|
|
|
|
|
void CreateScene();
|
|
|
|
|
2017-03-11 23:19:20 +00:00
|
|
|
public:
|
2017-03-12 11:03:54 +00:00
|
|
|
GLSceneDrawer()
|
|
|
|
{
|
|
|
|
GLPortal::drawer = this;
|
|
|
|
}
|
|
|
|
|
2017-03-11 23:19:20 +00:00
|
|
|
Clipper clipper;
|
2017-03-12 20:57:39 +00:00
|
|
|
int FixedColormap;
|
2017-03-12 22:13:07 +00:00
|
|
|
area_t in_area;
|
2018-04-02 07:27:40 +00:00
|
|
|
BitArray CurrentMapSections; // this cannot be a single number, because a group of portals with the same displacement may link different sections.
|
2017-03-12 11:03:54 +00:00
|
|
|
|
|
|
|
angle_t FrustumAngle();
|
|
|
|
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
|
|
|
void SetViewArea();
|
|
|
|
void SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror);
|
|
|
|
void SetViewAngle(DAngle viewangle);
|
|
|
|
void SetProjection(VSMatrix matrix);
|
|
|
|
void Set3DViewport(bool mainview);
|
2017-03-12 11:51:26 +00:00
|
|
|
void Reset3DViewport();
|
|
|
|
void SetFixedColormap(player_t *player);
|
2017-03-12 11:03:54 +00:00
|
|
|
void DrawScene(int drawmode);
|
|
|
|
void ProcessScene(bool toscreen = false);
|
2017-03-12 11:51:26 +00:00
|
|
|
void DrawBlend(sector_t * viewsector);
|
|
|
|
void EndDrawScene(sector_t * viewsector);
|
2018-01-06 04:11:12 +00:00
|
|
|
void DrawEndScene2D(sector_t * viewsector);
|
2018-04-01 20:26:57 +00:00
|
|
|
void RenderActorsInPortal(FLinePortalSpan *glport);
|
2017-03-12 11:51:26 +00:00
|
|
|
|
2017-03-12 22:13:07 +00:00
|
|
|
void CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
|
|
|
|
|
2017-03-12 11:51:26 +00:00
|
|
|
sector_t *RenderViewpoint(AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
|
|
|
void RenderView(player_t *player);
|
|
|
|
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
2017-03-11 23:19:20 +00:00
|
|
|
|
2017-03-12 20:57:39 +00:00
|
|
|
void DrawPSprite(player_t * player, DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
|
|
|
void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep);
|
|
|
|
void DrawTargeterSprites();
|
2018-04-02 07:27:40 +00:00
|
|
|
|
2017-03-11 23:19:20 +00:00
|
|
|
void InitClipper(angle_t a1, angle_t a2)
|
|
|
|
{
|
2017-05-09 10:20:49 +00:00
|
|
|
clipper.Clear();
|
2017-03-11 23:19:20 +00:00
|
|
|
clipper.SafeAddClipRangeRealAngles(a1, a2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetView()
|
|
|
|
{
|
2017-03-11 23:38:55 +00:00
|
|
|
viewx = FLOAT2FIXED(r_viewpoint.Pos.X);
|
|
|
|
viewy = FLOAT2FIXED(r_viewpoint.Pos.Y);
|
2017-03-11 23:19:20 +00:00
|
|
|
}
|
2017-03-12 20:57:39 +00:00
|
|
|
|
|
|
|
void SetColor(int light, int rellight, const FColormap &cm, float alpha, bool weapon = false)
|
|
|
|
{
|
|
|
|
gl_SetColor(light, rellight, FixedColormap != CM_DEFAULT, cm, alpha, weapon);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CheckFog(sector_t *frontsector, sector_t *backsector)
|
|
|
|
{
|
|
|
|
if (FixedColormap != CM_DEFAULT) return false;
|
|
|
|
return gl_CheckFog(frontsector, backsector);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isadditive)
|
|
|
|
{
|
|
|
|
gl_SetFog(lightlevel, rellight, FixedColormap != CM_DEFAULT, cmap, isadditive);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool isFullbright(PalEntry color, int lightlevel)
|
|
|
|
{
|
|
|
|
return FixedColormap != CM_DEFAULT || (gl_isWhite(color) && lightlevel == 255);
|
|
|
|
}
|
2017-03-11 23:19:20 +00:00
|
|
|
};
|