~alan-griffiths/mir/fix-1654023

« back to all changes in this revision

Viewing changes to examples/server_example_adorning_compositor.h

  • Committer: Daniel van Vugt
  • Date: 2015-04-28 07:54:10 UTC
  • mfrom: (2517 development-branch)
  • mto: This revision was merged to the branch mainline in revision 2673.
  • Revision ID: daniel.van.vugt@canonical.com-20150428075410-rwskshfuar7voesp
Merge latest trunk and fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2015 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored By: Kevin DuBois <kevin.dubois@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef MIR_EXAMPLES_ADORNING_COMPOSITOR_H_
 
20
#define MIR_EXAMPLES_ADORNING_COMPOSITOR_H_
 
21
#include "mir/compositor/display_buffer_compositor.h"
 
22
#include <GLES2/gl2.h>
 
23
#include <tuple>
 
24
 
 
25
namespace mir
 
26
{
 
27
namespace graphics
 
28
{
 
29
class DisplayBuffer;
 
30
}
 
31
namespace examples
 
32
{
 
33
class AdorningDisplayBufferCompositor : public compositor::DisplayBufferCompositor
 
34
{
 
35
public:
 
36
    AdorningDisplayBufferCompositor(graphics::DisplayBuffer&, std::tuple<float, float, float> const& background_rgb);
 
37
    void composite(compositor::SceneElementSequence&& scene_sequence) override;
 
38
private:
 
39
    graphics::DisplayBuffer& db;
 
40
    GLchar const*const vert_shader_src;
 
41
    GLchar const*const frag_shader_src;
 
42
    bool current;
 
43
    struct Shader
 
44
    {
 
45
        Shader(GLchar const* const* src, GLuint type);
 
46
        ~Shader();
 
47
        GLuint shader;
 
48
    } vertex, fragment;
 
49
    struct Program
 
50
    {
 
51
        Program(Shader& vertex, Shader& fragment);
 
52
        ~Program();
 
53
        GLuint program;
 
54
    } program;
 
55
 
 
56
    GLfloat vertex_data[16]
 
57
    {
 
58
        0.0f, 0.0f, 0.0f, 1.0f,
 
59
        0.0f, 1.0f, 0.0f, 1.0f,
 
60
        1.0f, 0.0f, 0.0f, 1.0f,
 
61
        1.0f, 1.0f, 0.0f, 1.0f,
 
62
    };
 
63
    GLfloat uv_data[8]
 
64
    {
 
65
        0.0f, 0.0f,
 
66
        0.0f, 1.0f,
 
67
        1.0f, 0.0f,
 
68
        1.0f, 1.0f,
 
69
 
 
70
    };
 
71
 
 
72
    GLuint vPositionAttr;
 
73
    GLuint uvCoord;
 
74
    GLuint scaleUniform;
 
75
    GLuint posUniform;
 
76
    GLuint alphaUniform; 
 
77
    GLuint texture;
 
78
};
 
79
}
 
80
}
 
81
 
 
82
#endif /* MIR_EXAMPLES_ADORNING_COMPOSITOR_H_ */