1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/********************************************************************
*
*	File:		fsITextRenderData.h
*
*	Purpose:	Information required to render text
*
*********************************************************************/

#ifndef fsITextRenderDatahdr
#define fsITextRenderDatahdr

#include "fsIRenderData.h"
#include "src/components/fsITextSpriteComponent.h"

class fsIFont;


class fsITextRenderData : public fsIRenderData
{
public:

	void outlineSet(const fsSColour4B& pOutline, fsF32 pSize) const;
	void shadowSet(const fsSColour4B& pShadow, fsVec2d pOffset, fsF32 pBlurRadius) const;
	void glowSet(const fsSColour4B& pGlow) const;

	virtual void implRender()
	{
	};

	virtual void uvsCopyToImpl()
	{
	};

	virtual void vertsCopyToImpl(void* const pImpl) const
	{
	};

	virtual void colourCopyToImpl(void* const pImpl) const
	{
	};

	fsS32 vertexCountGet() const;
	const fsIFont* fontGet() const;

	void dirtyTextProcess(const fsAffineMtx2d& pRenderMatrix, const fsRect& pFormattingRect, const fsStr& pText);

	void initialise(fsIFont* pFont);
	void formattingRectSizeSet(const fsRect& pFormatting);
	void alignmentSet(fsITextSpriteComponent::eHORIZONTAL_ALIGNMENT pAlignH,
	                  fsITextSpriteComponent::eVERTICAL_ALIGNMENT pAlignV);

	virtual fsS32 stringWidthInPixelsGet() const = 0;

	virtual ~fsITextRenderData();<--- Destructor in derived class

protected:

	virtual void outlineSetDo(const fsSColour4B& pOutline, fsF32 pSize) const {}
	virtual void shadowSetDo(const fsSColour4B& pShadow, fsVec2d pOffset, fsF32 pBlurRadius) const {}
	virtual void glowSetDo(const fsSColour4B& pGlow) const {}

	void passToEngineRendererDo(fsIRenderer* pRenderer, fsS32 pFirstMaterialIndex, fsS32 pLastMaterialInJob) override;

	void renderDo() override;

	void matrixApplyDo(const fsAffineMtx2d& pRenderMatrix) override;

	virtual void dirtyTextProcessDo(const fsAffineMtx2d& pRenderMatrix, const fsRect& pFormattingRect,
	                                const fsStr& pText) = 0;

	virtual void formattingRectSizeSetDo(const fsRect& pFormatting)
	{
	}

	virtual void alignmentSetDo()
	{
	};

	void buffersResize();

	fsITextRenderData();

	fsIFont* mFont;

	fsVec2d* mRawVerts;
	fsVec2d* mTransformedVerts;

	fsS32 mTotalCharacters;
	fsS32 mVertBufferSize;

	fsITextSpriteComponent::eHORIZONTAL_ALIGNMENT mAlignH;
	fsITextSpriteComponent::eVERTICAL_ALIGNMENT mAlignV;

private:
};

#endif