summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'shaders')
-rw-r--r--shaders/tile-shader.cpp12
-rw-r--r--shaders/tile-shader.hpp15
2 files changed, 15 insertions, 12 deletions
diff --git a/shaders/tile-shader.cpp b/shaders/tile-shader.cpp
index 4c694c9e..bda7114c 100644
--- a/shaders/tile-shader.cpp
+++ b/shaders/tile-shader.cpp
@@ -32,8 +32,8 @@ tile_shader::tile_shader()
tile_shader& tile_shader::set_scale(const Vector2& scale)
{
- if (scale != scale_)
- setUniform(ScaleUniform, scale_ = scale);
+ if (scale != _scale)
+ setUniform(ScaleUniform, _scale = scale);
return *this;
}
@@ -42,9 +42,9 @@ 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_)
+ if (camera_offset != _camera_offset)
{
- 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)});
}
@@ -53,8 +53,8 @@ tile_shader& tile_shader::set_camera_offset(Vector2d camera_offset)
tile_shader& tile_shader::set_tint(const Vector4& tint)
{
- if (tint != tint_)
- setUniform(TintUniform, tint_ = tint);
+ if (tint != _tint)
+ setUniform(TintUniform, _tint = tint);
return *this;
}
diff --git a/shaders/tile-shader.hpp b/shaders/tile-shader.hpp
index af0d778c..50402030 100644
--- a/shaders/tile-shader.hpp
+++ b/shaders/tile-shader.hpp
@@ -13,20 +13,23 @@ struct tile_shader : GL::AbstractShaderProgram
explicit tile_shader();
- Vector2 scale() const { return scale_; }
+ Vector2 scale() const { return _scale; }
tile_shader& set_scale(const Vector2& scale);
- Vector2d camera_offset() const { return camera_offset_; }
+ Vector2d camera_offset() const { return _camera_offset; }
tile_shader& set_camera_offset(Vector2d camera_offset);
- Vector4 tint() const { return tint_; }
+ Vector4 tint() const { return _tint; }
tile_shader& set_tint(const Vector4& tint);
static constexpr Vector2d project(Vector3d pt);
static constexpr Vector2d unproject(Vector2d px);
private:
- Vector2d camera_offset_;
- Vector2 scale_;
- Vector4 tint_;
+ void on_draw();
+
+ Vector2d _camera_offset;
+ Vector4 _tint;
+ Vector2 _scale;
+ Vector2i _real_camera_offset;
enum { ScaleUniform = 0, OffsetUniform = 1, TintUniform = 2, };
};