summaryrefslogtreecommitdiffhomepage
path: root/shaders/tile-shader.cpp
diff options
context:
space:
mode:
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