aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/RenderSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/system/RenderSystem.cpp')
-rw-r--r--src/crepe/system/RenderSystem.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index a1443cd..bfee658 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -11,6 +11,7 @@
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
#include "api/Camera.h"
+#include "types.h"
#include "RenderSystem.h"
@@ -33,7 +34,7 @@ const Camera & RenderSystem::update_camera() {
const Transform & transform
= mgr.get_components_by_id<Transform>(cam.game_object_id).front().get();
this->context.set_camera(cam);
- cam.pos = transform.position + cam.offset;
+ this->cam_pos = transform.position + cam.offset;
return cam;
}
throw std::runtime_error("No active cameras in current scene");
@@ -76,14 +77,32 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Camera & cam,
for (const Particle & p : em.data.particles) {
if (!p.active) continue;
- this->context.draw_particle(sprite, p.position, p.angle, scale, cam);
+
+ RenderCtx ctx{
+ .sprite = sprite,
+ .cam = cam,
+ .cam_pos = this->cam_pos,
+ .pos = p.position,
+ .angle = p.angle,
+ .scale = scale,
+ };
+ this->context.draw(ctx);
}
}
return rendering_particles;
}
void RenderSystem::render_normal(const Sprite & sprite, const Camera & cam,
const Transform & tm) {
- this->context.draw(sprite, tm, cam);
+
+ RenderCtx ctx{
+ .sprite = sprite,
+ .cam = cam,
+ .cam_pos = this->cam_pos,
+ .pos = tm.position,
+ .angle = tm.rotation,
+ .scale = tm.scale,
+ };
+ this->context.draw(ctx);
}
void RenderSystem::render() {