2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_RENDER_H
|
|
|
|
#define GAME_CLIENT_RENDER_H
|
|
|
|
|
2019-04-26 12:06:32 +00:00
|
|
|
#include <base/color.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <base/vmath.h>
|
2022-06-17 17:26:59 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
#include <game/client/skin.h>
|
2022-07-08 16:28:30 +00:00
|
|
|
#include <game/client/ui_rect.h>
|
2022-06-17 17:26:59 +00:00
|
|
|
|
|
|
|
class CSpeedupTile;
|
|
|
|
class CSwitchTile;
|
|
|
|
class CTeleTile;
|
|
|
|
class CTile;
|
|
|
|
class CTuneTile;
|
|
|
|
namespace client_data7 {
|
|
|
|
struct CDataSprite;
|
|
|
|
}
|
|
|
|
struct CDataSprite;
|
|
|
|
struct CEnvPoint;
|
|
|
|
struct CMapItemGroup;
|
2022-08-10 01:51:03 +00:00
|
|
|
struct CMapItemGroupEx;
|
2022-06-17 17:26:59 +00:00
|
|
|
struct CQuad;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-07-05 18:57:07 +00:00
|
|
|
class CTeeRenderInfo
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2010-07-05 18:57:07 +00:00
|
|
|
public:
|
2010-05-29 07:25:38 +00:00
|
|
|
CTeeRenderInfo()
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
m_ColorBody = ColorRGBA(1, 1, 1);
|
|
|
|
m_ColorFeet = ColorRGBA(1, 1, 1);
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Size = 1.0f;
|
|
|
|
m_GotAirJump = 1;
|
2022-06-14 17:30:01 +00:00
|
|
|
m_TeeRenderFlags = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
CSkin::SSkinTextures m_OriginalRenderSkin;
|
|
|
|
CSkin::SSkinTextures m_ColorableRenderSkin;
|
2020-11-08 05:39:16 +00:00
|
|
|
|
|
|
|
CSkin::SSkinMetrics m_SkinMetrics;
|
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
bool m_CustomColoredSkin;
|
|
|
|
ColorRGBA m_BloodColor;
|
|
|
|
|
2019-04-26 12:06:32 +00:00
|
|
|
ColorRGBA m_ColorBody;
|
|
|
|
ColorRGBA m_ColorFeet;
|
2010-05-29 07:25:38 +00:00
|
|
|
float m_Size;
|
|
|
|
int m_GotAirJump;
|
2022-06-14 17:30:01 +00:00
|
|
|
int m_TeeRenderFlags;
|
2022-09-03 07:59:39 +00:00
|
|
|
bool m_FeetFlipped;
|
2022-06-14 17:30:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Tee Render Flags
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEE_EFFECT_FROZEN = 1,
|
|
|
|
TEE_NO_WEAPON = 2,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// sprite renderings
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SPRITE_FLAG_FLIP_Y = 1,
|
|
|
|
SPRITE_FLAG_FLIP_X = 2,
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
LAYERRENDERFLAG_OPAQUE = 1,
|
|
|
|
LAYERRENDERFLAG_TRANSPARENT = 2,
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
TILERENDERFLAG_EXTEND = 4,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2022-07-01 04:42:36 +00:00
|
|
|
typedef void (*ENVELOPE_EVAL)(int TimeOffsetMillis, int Env, ColorRGBA &Channels, void *pUser);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
class CRenderTools
|
|
|
|
{
|
2022-05-14 11:31:07 +00:00
|
|
|
class IGraphics *m_pGraphics;
|
|
|
|
class ITextRender *m_pTextRender;
|
|
|
|
|
2018-03-13 20:53:54 +00:00
|
|
|
int m_TeeQuadContainerIndex;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2020-11-08 05:39:16 +00:00
|
|
|
void GetRenderTeeBodyScale(float BaseSize, float &BodyScale);
|
|
|
|
void GetRenderTeeFeetScale(float BaseSize, float &FeetScaleWidth, float &FeetScaleHeight);
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
class IGraphics *Graphics() const { return m_pGraphics; }
|
2022-05-14 11:31:07 +00:00
|
|
|
class ITextRender *TextRender() const { return m_pTextRender; }
|
2018-03-13 20:53:54 +00:00
|
|
|
|
2022-05-14 11:31:07 +00:00
|
|
|
void Init(class IGraphics *pGraphics, class ITextRender *pTextRender);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-06-17 17:26:59 +00:00
|
|
|
void SelectSprite(CDataSprite *pSprite, int Flags = 0, int sx = 0, int sy = 0);
|
2022-05-14 17:08:43 +00:00
|
|
|
void SelectSprite(int Id, int Flags = 0, int sx = 0, int sy = 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
void GetSpriteScale(client_data7::CDataSprite *pSprite, float &ScaleX, float &ScaleY);
|
2022-06-17 17:26:59 +00:00
|
|
|
void GetSpriteScale(CDataSprite *pSprite, float &ScaleX, float &ScaleY);
|
2022-05-14 17:08:43 +00:00
|
|
|
void GetSpriteScale(int Id, float &ScaleX, float &ScaleY);
|
2020-10-25 13:32:41 +00:00
|
|
|
void GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY);
|
2020-10-09 07:07:05 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void DrawSprite(float x, float y, float size);
|
2020-10-09 07:07:05 +00:00
|
|
|
void DrawSprite(float x, float y, float ScaledWidth, float ScaledHeight);
|
2022-05-27 17:30:20 +00:00
|
|
|
void RenderCursor(vec2 Center, float Size);
|
2022-06-25 15:15:37 +00:00
|
|
|
void RenderIcon(int ImageId, int SpriteId, const CUIRect *pRect, const ColorRGBA *pColor = nullptr);
|
2022-02-18 10:16:55 +00:00
|
|
|
int QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float size);
|
|
|
|
int QuadContainerAddSprite(int QuadContainerIndex, float size);
|
|
|
|
int QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height);
|
|
|
|
int QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// larger rendering methods
|
2020-11-08 05:39:16 +00:00
|
|
|
void GetRenderTeeBodySize(class CAnimState *pAnim, CTeeRenderInfo *pInfo, vec2 &BodyOffset, float &Width, float &Height);
|
|
|
|
void GetRenderTeeFeetSize(class CAnimState *pAnim, CTeeRenderInfo *pInfo, vec2 &FeetOffset, float &Width, float &Height);
|
2022-06-14 17:30:01 +00:00
|
|
|
void GetRenderTeeAnimScaleAndBaseSize(class CAnimState *pAnim, CTeeRenderInfo *pInfo, float &AnimScale, float &BaseSize);
|
2020-11-08 05:39:16 +00:00
|
|
|
|
|
|
|
// returns the offset to use, to render the tee with @see RenderTee exactly in the mid
|
|
|
|
void GetRenderTeeOffsetToRenderedTee(class CAnimState *pAnim, CTeeRenderInfo *pInfo, vec2 &TeeOffsetToMid);
|
2022-05-14 11:44:12 +00:00
|
|
|
// object render methods
|
2019-04-21 16:20:53 +00:00
|
|
|
void RenderTee(class CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos, float Alpha = 1.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-14 11:44:12 +00:00
|
|
|
// map render methods (render_map.cpp)
|
2022-07-01 04:42:36 +00:00
|
|
|
static void RenderEvalEnvelope(CEnvPoint *pPoints, int NumPoints, int Channels, std::chrono::nanoseconds TimeNanos, ColorRGBA &Result);
|
2011-07-18 10:05:12 +00:00
|
|
|
void RenderQuads(CQuad *pQuads, int NumQuads, int Flags, ENVELOPE_EVAL pfnEval, void *pUser);
|
2014-05-08 13:58:59 +00:00
|
|
|
void ForceRenderQuads(CQuad *pQuads, int NumQuads, int Flags, ENVELOPE_EVAL pfnEval, void *pUser, float Alpha = 1.0f);
|
2019-04-26 22:11:15 +00:00
|
|
|
void RenderTilemap(CTile *pTiles, int w, int h, float Scale, ColorRGBA Color, int RenderFlags, ENVELOPE_EVAL pfnEval, void *pUser, int ColorEnv, int ColorEnvOffset);
|
2017-03-16 15:37:40 +00:00
|
|
|
|
|
|
|
// render a rectangle made of IndexIn tiles, over a background made of IndexOut tiles
|
|
|
|
// the rectangle include all tiles in [RectX, RectX+RectW-1] x [RectY, RectY+RectH-1]
|
2019-04-26 22:11:15 +00:00
|
|
|
void RenderTileRectangle(int RectX, int RectY, int RectW, int RectH, unsigned char IndexIn, unsigned char IndexOut, float Scale, ColorRGBA Color, int RenderFlags, ENVELOPE_EVAL pfnEval, void *pUser, int ColorEnv, int ColorEnvOffset);
|
2017-03-16 15:37:40 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// helpers
|
2022-06-30 22:36:32 +00:00
|
|
|
void CalcScreenParams(float Aspect, float Zoom, float *pWidth, float *pHeight);
|
2022-05-17 13:00:06 +00:00
|
|
|
void MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
|
2022-08-04 23:16:44 +00:00
|
|
|
float ParallaxZoom, float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints);
|
2022-08-10 01:51:03 +00:00
|
|
|
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, CMapItemGroupEx *pGroupEx, float Zoom);
|
2022-08-04 23:16:44 +00:00
|
|
|
void MapScreenToInterface(float CenterX, float CenterY);
|
2011-04-09 06:41:31 +00:00
|
|
|
|
|
|
|
// DDRace
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
void RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale, float Alpha = 1.0f);
|
2022-01-22 13:12:59 +00:00
|
|
|
void RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, float Scale, float Alpha = 1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
void RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float Scale, float Alpha = 1.0f);
|
|
|
|
void RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale, float Alpha = 1.0f);
|
2019-04-26 22:11:15 +00:00
|
|
|
void RenderTelemap(CTeleTile *pTele, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
|
2022-01-22 13:12:59 +00:00
|
|
|
void RenderSpeedupmap(CSpeedupTile *pSpeedup, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
|
2019-04-26 22:11:15 +00:00
|
|
|
void RenderSwitchmap(CSwitchTile *pSwitch, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
|
|
|
|
void RenderTunemap(CTuneTile *pTune, int w, int h, float Scale, ColorRGBA Color, int RenderFlags);
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|