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.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 1bf5f65..b5db45a 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -21,7 +21,7 @@ void RenderSystem::clear_screen() { this->context.clear_screen(); }
void RenderSystem::present_screen() { this->context.present_screen(); }
-const Camera & RenderSystem::update_camera() {
+SDLContext::CameraValues RenderSystem::update_camera() {
ComponentManager & mgr = this->component_manager;
RefVector<Camera> cameras = mgr.get_components_by_type<Camera>();
@@ -32,9 +32,9 @@ const Camera & RenderSystem::update_camera() {
if (!cam.active) continue;
const Transform & transform
= mgr.get_components_by_id<Transform>(cam.game_object_id).front().get();
- this->context.set_camera(cam, this->cam_ctx);
- this->cam_ctx.cam_pos = transform.position + cam.data.offset;
- return cam;
+ SDLContext::CameraValues cam_val = this->context.set_camera(cam);
+ cam_val.cam_pos = transform.position + cam.data.offset;
+ return cam_val;
}
throw std::runtime_error("No active cameras in current scene");
}
@@ -60,7 +60,7 @@ void RenderSystem::update() {
this->present_screen();
}
-bool RenderSystem::render_particle(const Sprite & sprite, const Camera & cam,
+bool RenderSystem::render_particle(const Sprite & sprite, const SDLContext::CameraValues & cam,
const double & scale) {
ComponentManager & mgr = this->component_manager;
@@ -80,7 +80,7 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Camera & cam,
this->context.draw(SDLContext::RenderContext{
.sprite = sprite,
- .cam = this->cam_ctx,
+ .cam = cam,
.pos = p.position,
.angle = p.angle,
.scale = scale,
@@ -89,11 +89,10 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Camera & cam,
}
return rendering_particles;
}
-void RenderSystem::render_normal(const Sprite & sprite, const Camera & cam,
- const Transform & tm) {
+void RenderSystem::render_normal(const Sprite & sprite, const SDLContext::CameraValues & cam, const Transform & tm) {
this->context.draw(SDLContext::RenderContext{
.sprite = sprite,
- .cam = this->cam_ctx,
+ .cam = cam,
.pos = tm.position,
.angle = tm.rotation,
.scale = tm.scale,
@@ -102,7 +101,7 @@ void RenderSystem::render_normal(const Sprite & sprite, const Camera & cam,
void RenderSystem::render() {
ComponentManager & mgr = this->component_manager;
- const Camera & cam = this->update_camera();
+ const SDLContext::CameraValues & cam = this->update_camera();
RefVector<Sprite> sprites = mgr.get_components_by_type<Sprite>();
RefVector<Sprite> sorted_sprites = this->sort(sprites);