summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/debugging.cpp
blob: 0d69d58be56acbacc1c58aa22d182b03eb215306 (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
32
33
#include <mbgl/gl/debugging.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/debugging_extension.hpp>

namespace mbgl {
namespace gl {

#ifndef NDEBUG

DebugGroup::DebugGroup(const Context& context_, const std::string& name) : context(context_) {
    if (auto debugging = context.getDebuggingExtension()) {
        if (debugging->pushDebugGroup) {
            debugging->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(name.size()), name.c_str());
        } else if (debugging->pushGroupMarkerEXT) {
            debugging->pushGroupMarkerEXT(GLsizei(name.size() + 1), name.c_str());
        }
    }
}

DebugGroup::~DebugGroup() {
    if (auto debugging = context.getDebuggingExtension()) {
        if (debugging->popDebugGroup) {
            debugging->popDebugGroup();
        } else if (debugging->popGroupMarkerEXT) {
            debugging->popGroupMarkerEXT();
        }
    }
}

#endif

} // namespace gl
} // namespace mbgl