diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-07-27 18:01:44 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-07-27 18:01:44 +0200 |
| commit | 97cfca98bde2a74257e2fa0d9112b77e4fa824f1 (patch) | |
| tree | 4afa25ab5778d3581d1dfdf84654d67a041a3480 /tile-shader.cpp | |
| parent | 108ae0682d5d45eafc8dabe58b4509a54c66d837 (diff) | |
aa
Diffstat (limited to 'tile-shader.cpp')
| -rw-r--r-- | tile-shader.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tile-shader.cpp b/tile-shader.cpp index ba1e135f..ec6c8751 100644 --- a/tile-shader.cpp +++ b/tile-shader.cpp @@ -25,7 +25,7 @@ tile_shader::tile_shader() CORRADE_INTERNAL_ASSERT_OUTPUT(link()); - setUniform(TextureUnit, TextureUnit); + setUniform(ScaleUniform, Vector2{640, 480}); } tile_shader& tile_shader::bindTexture(GL::Texture2D& texture) @@ -36,8 +36,20 @@ tile_shader& tile_shader::bindTexture(GL::Texture2D& texture) tile_shader& tile_shader::set_scale(const Vector2& scale) { - setUniform(ProjectionUniform, scale); + scale_ = scale; + setUniform(ScaleUniform, scale); return *this; } +tile_shader& tile_shader::set_camera_offset(Vector2 camera_offset) +{ + camera_offset_ = camera_offset; + setUniform(OffsetUniform, camera_offset); + return *this; +} +Vector2 tile_shader::project(Vector3 pt) const +{ + float x = pt[1], y = pt[0], z = pt[2]; + return { x-y+camera_offset_[0], (x+y+z*2)*.75f - camera_offset_[1] }; +} } // namespace Magnum::Examples |
