-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderComponent.h
83 lines (68 loc) · 1.71 KB
/
RenderComponent.h
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
#pragma once
#include <map>
#include "Component.h"
#include "surface.h"
#include "template.h"
typedef unsigned int Pixel;
struct RenderObject
{
RenderObject(float x, float y, tmpl8::Sprite& sprite, tmpl8::Surface* screen) :
pos(x, y),
sprite(sprite),
dst(screen)
{}
RenderObject(tmpl8::vec2 pos, tmpl8::Sprite& sprite, tmpl8::Surface* screen) :
pos(pos),
sprite(sprite),
dst(screen)
{}
tmpl8::vec2 pos;
tmpl8::Sprite& sprite;
tmpl8::Surface* dst;
};
class RenderComponent :
public Component
{
public:
RenderComponent(tmpl8::Surface* surface, int numFrames) :
sprite(surface, numFrames)
{}
/// <summary>
/// queues the object for render
/// </summary>
/// <param name="entity"></param>
/// <param name="screen"></param>
void Render(Entity& entity, tmpl8::Surface& screen) override;
/// <summary>
/// renders the object queue
/// </summary>
static void RenderAll();
/// <summary>
/// set the frame
/// </summary>
/// <param name="a_Index"></param>
void SetFrame(unsigned int a_Index);
/// <summary>
/// gets the width of the sprite
/// </summary>
/// <returns></returns>
int GetWidth() const;
/// <summary>
/// gets the height of the sprite
/// </summary>
/// <returns></returns>
int GetHeight() const;
/// <summary>
/// gets the buffer of the sprite surface location
/// </summary>
/// <returns></returns>
Pixel* GetBuffer() const;
/// <summary>
/// gets the frames of the sprite
/// </summary>
/// <returns></returns>
unsigned int Frames() const;
private:
tmpl8::Sprite sprite;
static std::multimap<float, RenderObject> renderQueue;
};