diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-25 16:41:21 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-25 16:41:21 +0200 |
| commit | 0d97856bf6974450a8e72816be7bf271af04a458 (patch) | |
| tree | a503cf7d7330970b468310a9c05860b8fbc7f3e4 /shaders/tile-shader.cpp | |
| parent | f1df7c20129a1f1cc47c47e5731efd10f8e49aeb (diff) | |
rename shader
Diffstat (limited to 'shaders/tile-shader.cpp')
| -rw-r--r-- | shaders/tile-shader.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/shaders/tile-shader.cpp b/shaders/tile-shader.cpp deleted file mode 100644 index 50444cc8..00000000 --- a/shaders/tile-shader.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "shaders/tile-shader.hpp" -#include "loader.hpp" -#include "compat/assert.hpp" -#include <Magnum/Math/Vector4.h> -#include <Magnum/GL/Context.h> -#include <Magnum/GL/Shader.h> -#include <Magnum/GL/Version.h> - -namespace floormat { - -tile_shader::tile_shader() -{ - MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL460); - - GL::Shader vert{GL::Version::GL460, GL::Shader::Type::Vertex}; - GL::Shader frag{GL::Version::GL460, GL::Shader::Type::Fragment}; - - vert.addSource(loader.shader("shaders/tile-shader.vert")); - frag.addSource(loader.shader("shaders/tile-shader.frag")); - CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile()); - CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile()); - attachShaders({vert, frag}); - CORRADE_INTERNAL_ASSERT_OUTPUT(link()); - - set_scale({640, 480}); - set_camera_offset({0, 0}); - set_tint({1, 1, 1, 1}); -} - -tile_shader::~tile_shader() = default; - -tile_shader& tile_shader::set_scale(const Vector2& scale) -{ - if (scale != _scale) - setUniform(ScaleUniform, _scale = scale); - return *this; -} - -tile_shader& tile_shader::set_camera_offset(Vector2d camera_offset) -{ - _camera_offset = camera_offset; - return *this; -} - -tile_shader& tile_shader::set_tint(const Vector4& tint) -{ - if (tint != _tint) - setUniform(TintUniform, _tint = tint); - return *this; -} - -void tile_shader::_draw() -{ - if (const auto offset = Vector2{(float)_camera_offset[0], (float)_camera_offset[1]}; - offset != _real_camera_offset) - { - fm_assert(offset[0] < 1 << 24 && offset[1] < 1 << 24); - _real_camera_offset = offset; - setUniform(OffsetUniform, offset); - } -} - -} // namespace floormat |
