summaryrefslogtreecommitdiffhomepage
path: root/shaders/tile-shader.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-18 03:00:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-18 03:00:56 +0200
commit1a95ead477a0bebbb7017b6b0423ce82cca3ea78 (patch)
treedbc6728ff50ec2721ea2f61a0f13e3252d3eb763 /shaders/tile-shader.cpp
parentb7c90db8cc966ed7bff33fba1a49de2c384e5e38 (diff)
a
Diffstat (limited to 'shaders/tile-shader.cpp')
-rw-r--r--shaders/tile-shader.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/shaders/tile-shader.cpp b/shaders/tile-shader.cpp
index bda7114c..93c6a5c8 100644
--- a/shaders/tile-shader.cpp
+++ b/shaders/tile-shader.cpp
@@ -42,11 +42,7 @@ tile_shader& tile_shader::set_camera_offset(Vector2d camera_offset)
static constexpr auto MAX = std::numeric_limits<std::int32_t>::max();
ASSERT(std::fabs(camera_offset[0]) <= MAX);
ASSERT(std::fabs(camera_offset[1]) <= MAX);
- if (camera_offset != _camera_offset)
- {
- _camera_offset = camera_offset;
- setUniform(OffsetUniform, Vector2i{std::int32_t(camera_offset[0]*2), std::int32_t(camera_offset[1]*2)});
- }
+ _camera_offset = camera_offset;
return *this;
}
@@ -58,4 +54,14 @@ tile_shader& tile_shader::set_tint(const Vector4& tint)
return *this;
}
+void tile_shader::on_draw()
+{
+ if (const auto offset = Vector2i{(std::int32_t)_camera_offset[0], (std::int32_t)_camera_offset[1]};
+ offset != _real_camera_offset)
+ {
+ _real_camera_offset = offset;
+ setUniform(OffsetUniform, offset);
+ }
+}
+
} // namespace floormat