summaryrefslogtreecommitdiff
path: root/src/renderer/painter_composite.cpp
blob: 42d0ad55921abde54e630f4572f442d5eae8d1da (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
29
30
31
#include <mbgl/renderer/painter.hpp>
#include <mbgl/style/style_properties.hpp>

#include <iostream>

using namespace mbgl;

void Painter::drawComposite(GLuint texture, const CompositeProperties &properties) {
    // We're doing full-screen framebuffer blending, so no need to do stencil testing here.
    glDisable(GL_STENCIL_TEST);

    useProgram(compositeShader->program);
    compositeShader->setMatrix(nativeMatrix);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture);
    compositeShader->setImage(0);

    // TODO: translate
    compositeShader->setOpacity(properties.opacity);

    // Draw the full screen texture.
    // TODO: Do more blend effects like multiply + blur
    compositeArray.bind(*compositeShader, tileStencilBuffer, BUFFER_OFFSET(0));
    glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());

    glBindTexture(GL_TEXTURE_2D, 0);

    // Reset back.
    glEnable(GL_STENCIL_TEST);
}