summaryrefslogtreecommitdiffhomepage
path: root/tile-shader.hpp
blob: 4be4fe4ece4f01c6b2b6465975f632d84971e50c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <Magnum/GL/AbstractShaderProgram.h>
#include <Magnum/GL/Texture.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h>
#include <Magnum/Math/Matrix4.h>

namespace Magnum::Examples {

struct tile_shader : GL::AbstractShaderProgram
{
    typedef GL::Attribute<0, Vector3> Position;
    typedef GL::Attribute<1, Vector2> TextureCoordinates;

    explicit tile_shader();

    tile_shader& set_color(const Color3& color) { setUniform(_color_uniform, color); return *this; }
    tile_shader& set_projection(const Math::Matrix4<float>& mat, float y_scale);

    tile_shader& bindTexture(GL::Texture2D& texture);

private:
    enum: Int { TextureUnit = 0 };

    Int _color_uniform, _projection_uniform, _y_scale_uniform;
};

} // namespace Magnum::Examples