summaryrefslogtreecommitdiff
path: root/Runtime/GUI/UIMesh.h
blob: 1de111b2f9c4593123ef6143b714d96999d30148 (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
#pragma once 

#include "Runtime/Utilities/Exception.h"
#include "Runtime/Rendering/DynamicMesh.h"
#include "Runtime/Math/Math.h"
#include "Runtime/Utilities/StaticInitiator.h"
#include "Runtime/Graphics/CustomVertexLayout.h"
#include "Runtime/Graphics/DefaultVertexLayout.h"
#include "Runtime/Graphics/Color.h"
#include "Runtime/Graphics/GfxDevice.h"

// UI默认的顶点布局
struct UIVertexLayout
{
    UIVertexLayout(Vector2 pos = Vector2::zero, Vector2 texCoord = Vector2::zero, Color32 col = Color32())
    {
        position = pos; 
        uv = texCoord;
        color = col;
    }

	Vector2 position;
	Vector2 uv;
	Color32 color;
};

typedef uint16 UIIndex;

CustomException(UIMeshException);

// 所有的UIMesh都是左上角为原点
class UIMesh : public DynamicMesh
{
public:
	UIMesh() : DynamicMesh() {}
	virtual ~UIMesh() {}

	virtual void Draw() = 0;

	static CustomVertexLayout s_UIVertexLayout;
	static unsigned int s_SizePerVertex;
};