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 IMap *pMap);
43 void SetPointsRange(int StartPoint, int NumPoints);
44 int StartPoint() const;
45 int NumPoints() const override;
46 int NumPointsMax() const;
47 const CEnvPoint *GetPoint(int Index) const override;
48 const CEnvPointBezier *GetBezier(int Index) const override;
49};
50
51class IGraphics;
52class ITextRender;
53
54class CRenderMap
55{
56 IGraphics *m_pGraphics;
57 ITextRender *m_pTextRender;
58
59public:
60 void Init(IGraphics *pGraphics, ITextRender *pTextRender);
61 IGraphics *Graphics() { return m_pGraphics; }
62 ITextRender *TextRender() { return m_pTextRender; }
63
64 // map render methods (render_map.cpp)
65 static void RenderEvalEnvelope(const IEnvelopePointAccess *pPoints, std::chrono::nanoseconds TimeNanos, ColorRGBA &Result, size_t Channels);
66 void ForceRenderQuads(CQuad *pQuads, int NumQuads, int Flags, IEnvelopeEval *pEnvEval, float Alpha = 1.0f);
67 void RenderTile(int x, int y, unsigned char Index, float Scale, ColorRGBA Color);
68 void RenderTilemap(CTile *pTiles, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
69
70 // render a rectangle made of IndexIn tiles, over a background made of IndexOut tiles
71 // the rectangle include all tiles in [RectX, RectX+RectW-1] x [RectY, RectY+RectH-1]
72 void RenderTileRectangle(int RectX, int RectY, int RectW, int RectH, unsigned char IndexIn, unsigned char IndexOut, float Scale, ColorRGBA Color, int RenderFlags);
73
74 // DDRace
75 void RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
76 void RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
77 void RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
78 void RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale, int OverlayRenderFlags, float Alpha = 1.0f);
79 void RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
80 void RenderSwitchmap(CSwitchTile *pSwitch, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
81 void RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
82
83 void RenderDebugClip(float ClipX, float ClipY, float ClipW, float ClipH, ColorRGBA Color, float Zoom, const char *pLabel);
84};
85
86#endif
87