1#ifndef GAME_MAP_RENDER_MAP_H
2#define GAME_MAP_RENDER_MAP_H
3
4#include <base/color.h>
5
6#include <game/map/render_interfaces.h>
7#include <game/mapitems.h>
8
9#include <chrono>
10
11enum
12{
13 LAYERRENDERFLAG_OPAQUE = 1,
14 LAYERRENDERFLAG_TRANSPARENT = 2,
15
16 TILERENDERFLAG_EXTEND = 4,
17
18 OVERLAYRENDERFLAG_TEXT = 1,
19 OVERLAYRENDERFLAG_EDITOR = 2,
20};
21
22class IEnvelopePointAccess
23{
24public:
25 virtual ~IEnvelopePointAccess() = default;
26 virtual int NumPoints() const = 0;
27 virtual const CEnvPoint *GetPoint(int Index) const = 0;
28 virtual const CEnvPointBezier *GetBezier(int Index) const = 0;
29 int FindPointIndex(CFixedTime Time) const;
30};
31
32class CMapBasedEnvelopePointAccess : public IEnvelopePointAccess
33{
34 int m_StartPoint;
35 int m_NumPoints;
36 int m_NumPointsMax;
37 CEnvPoint *m_pPoints;
38 CEnvPointBezier *m_pPointsBezier;
39 CEnvPointBezier_upstream *m_pPointsBezierUpstream;
40
41public:
42 CMapBasedEnvelopePointAccess(class CDataFileReader *pReader);
43 CMapBasedEnvelopePointAccess(class IMap *pMap);
44 void SetPointsRange(int StartPoint, int NumPoints);
45 int StartPoint() const;
46 int NumPoints() const override;
47 int NumPointsMax() const;
48 const CEnvPoint *GetPoint(int Index) const override;
49 const CEnvPointBezier *GetBezier(int Index) const override;
50};
51
52class IGraphics;
53class ITextRender;
54
55class CRenderMap
56{
57 IGraphics *m_pGraphics;
58 ITextRender *m_pTextRender;
59
60public:
61 void Init(IGraphics *pGraphics, ITextRender *pTextRender);
62 IGraphics *Graphics() { return m_pGraphics; }
63 ITextRender *TextRender() { return m_pTextRender; }
64
65 // map render methods (render_map.cpp)
66 static void RenderEvalEnvelope(const IEnvelopePointAccess *pPoints, std::chrono::nanoseconds TimeNanos, ColorRGBA &Result, size_t Channels);
67 void ForceRenderQuads(CQuad *pQuads, int NumQuads, int Flags, IEnvelopeEval *pEnvEval, float Alpha = 1.0f);
68 void RenderTile(int x, int y, unsigned char Index, float Scale, ColorRGBA Color);
69 void RenderTilemap(CTile *pTiles, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
70
71 // render a rectangle made of IndexIn tiles, over a background made of IndexOut tiles
72 // the rectangle include all tiles in [RectX, RectX+RectW-1] x [RectY, RectY+RectH-1]
73 void RenderTileRectangle(int RectX, int RectY, int RectW, int RectH, unsigned char IndexIn, unsigned char IndexOut, float Scale, ColorRGBA Color, int RenderFlags);
74
75 // DDRace
76 void RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
77 void RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
78 void RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
79 void RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
80 void RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
81 void RenderSwitchmap(CSwitchTile *pSwitch, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
82 void RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
83
84 void RenderDebugClip(float ClipX, float ClipY, float ClipW, float ClipH, ColorRGBA Color, float Zoom, const char *pLabel);
85};
86
87#endif
88