#include "tile-shader.hpp" #include "loader.hpp" #include #include #include #include #include namespace Magnum::Examples { 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(GL::Shader::compile({vert, frag})); attachShaders({vert, frag}); CORRADE_INTERNAL_ASSERT_OUTPUT(link()); _color_uniform = uniformLocation("color"); _projection_uniform = uniformLocation("projection"); _y_scale_uniform = uniformLocation("y_scale"); setUniform(uniformLocation("textureData"), TextureUnit); } tile_shader& tile_shader::bindTexture(GL::Texture2D& texture) { texture.bind(TextureUnit); return *this; } tile_shader& tile_shader::set_projection(const Matrix4& mat, float y_scale) { setUniform(_projection_uniform, mat); setUniform(_y_scale_uniform, y_scale); return *this; } } // namespace Magnum::Examples