summaryrefslogtreecommitdiffhomepage
path: root/main/debug.cpp
blob: 7e7e3abfa169ccd6feed8c91179c40a9ebf56a3a (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
34
35
#include "app.hpp"
#include <Magnum/GL/Renderer.h>

namespace Magnum::Examples {

using Feature = GL::Renderer::Feature;
using Severity = GL::DebugOutput::Severity;
using Type = GL::DebugOutput::Type;
using GL::Renderer;
using GL::DebugOutput;

void app::debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Type type, UnsignedInt id,
                         GL::DebugOutput::Severity severity, const std::string& str) const
{
    std::fputs(str.c_str(), stdout);
    std::fputc('\n', stdout);
    std::fflush(stdout);
    std::puts(""); // put breakpoint here
}

static void _debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Type type, UnsignedInt id,
                            GL::DebugOutput::Severity severity, const std::string& str, const void* self)
{
    static_cast<const app*>(self)->debug_callback(src, type, id, severity, str);
}

void app::register_debug_callback()
{
    GL::Renderer::setFeature(Feature::DebugOutput, true);
    GL::Renderer::setFeature(Feature::DebugOutputSynchronous, true);
    GL::DebugOutput::setCallback(_debug_callback, this);
    GL::DebugOutput::setEnabled(Severity::High, true);
}

} // namespace Magnum::Examples