summaryrefslogtreecommitdiff
path: root/Runtime/GUI/TextMesh.h
blob: c091a785bf10eeb68737a4764497993e521ac666 (plain)
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
#pragma once
#include "../Graphics/VertexBuffer.h"
#include "Font.h"
#include "Runtime/Utilities/Exception.h"
#include <unordered_map>

CustomException(TextMeshException);

enum ETextAnchor
{
    TextAnchor_UpperLeft,
    TextAnchor_UpperCenter,
    TextAnchor_UpperRight,
    TextAnchor_MiddleLeft,
    TextAnchor_MiddleCenter,
    TextAnchor_MiddleRight,
    TextAnchor_LowerLeft,
    TextAnchor_LowerCenter,
    TextAnchor_LowerRight,
    TextAnchor_DontCare		
};

enum ETextAlignment {
    TextAlignment_Left,
    TextAlignment_Center,
    TextAlignment_Right,
    TextAlignment_Auto,
};

typedef unsigned long long TextMeshHash;

namespace TextHelper
{
	TextMeshHash GetTextMeshHash();
}

// 一段文字里面的网格可能会来自不同的atlas,在生成TextMesh时做好合批

class TextMesh
{
public:
	TextMesh(const UnicodeString& str, Font* font, int pixelSize, ETextAnchor anchor, ETextAlignment alignment)/*throw TextMeshException*/;

	~TextMesh();

	void Draw();

private: 
	Font* m_Font;
	std::unordered_map<int/*IndexOfAtlas*/, VertexBuffer*> m_VBOs;
	
};