gs-helper: Add class for managed debug markers

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-10-18 22:59:30 +02:00
parent 9b0ea98243
commit 90cdc30ef1
2 changed files with 33 additions and 0 deletions

View file

@ -28,3 +28,27 @@ gs::context::~context()
{
obs_leave_graphics();
}
gs::debug_marker::debug_marker(const float color[4], std::string name) : _name(name)
{
gs_debug_marker_begin(color, _name.c_str());
}
gs::debug_marker::debug_marker(const float color[4], std::string format, ...)
{
size_t size;
std::vector<char> buffer(64);
va_list vargs;
va_start(vargs, format);
size = vsnprintf(buffer.data(), buffer.size(), format.c_str(), vargs);
va_end(vargs);
_name = std::string(buffer.data(), buffer.data() + size);
gs_debug_marker_begin(color, _name.c_str());
}
gs::debug_marker::~debug_marker()
{
gs_debug_marker_end();
}

View file

@ -37,4 +37,13 @@ namespace gs {
context();
~context();
};
class debug_marker {
std::string _name;
public:
debug_marker(const float color[4], std::string name);
debug_marker(const float color[4], std::string format, ...);
~debug_marker();
};
} // namespace gs