-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderSystem.cpp
More file actions
38 lines (26 loc) · 1.07 KB
/
Copy pathRenderSystem.cpp
File metadata and controls
38 lines (26 loc) · 1.07 KB
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
#include "RenderSystem.h"
#include <GLFW/glfw3.h>
RenderSystem::RenderSystem(int width, int height) {
projection = glm::ortho(0.0f, static_cast<float>(width), static_cast<float>(height), 0.0f, -1.0f, 1.0f);
sr.Init();
}
double prevTime = glfwGetTime();
void RenderSystem::tick(World* world, float deltaTime)
{
t += glfwGetTime() - prevTime;
prevTime = glfwGetTime();
sr.SetTime(t);
world->each<Sprite>([&](Entity* ent, ComponentHandle<Sprite> sprite) {
//cout << "render" << endl;
ComponentHandle<Transform> transform = ent->get<Transform>();
Texture texture = textureManager.GetTexture(sprite->filepath);
if (sprite->visible) {
if (sprite->autoSize) {
sr.DrawSprite(texture, projection, transform->position, texture.GetSize(), transform->rotation, sprite->color, sprite->shaderName);
}
else {
sr.DrawSprite(texture, projection, transform->position, sprite->size, transform->rotation, sprite->color, sprite->shaderName);
}
}
});
}