diff --git a/include/opengl.hpp b/include/opengl.hpp index 16ed8221..9ecbc4c6 100644 --- a/include/opengl.hpp +++ b/include/opengl.hpp @@ -20,6 +20,7 @@ #pragma once #include #include +#include #include #include #include @@ -43,6 +44,15 @@ #include #endif +#ifdef _MSC_VER +#include +#define OPENGL_PRINTF_FORMAT _Printf_format_string_ +#define OPENGL_PRINTF_FORMAT_ATTR(format_arg_index, dots_arg_index) +#else +#define OPENGL_PRINTF_FORMAT +#define OPENGL_PRINTF_FORMAT_ATTR(format_arg_index, dots_arg_index) __attribute__((__format__(__printf__, format_arg_index, dots_arg_index))) +#endif + // Uncomment the following define if you want GL objects to automatically free themselves when their lifetime ends // #define OPENGL_DESTRUCTORS @@ -53,6 +63,16 @@ namespace OpenGL { template constexpr std::false_type AlwaysFalse{}; + OPENGL_PRINTF_FORMAT_ATTR(3, 4) + static void setObjectLabel(GLenum identifier, GLuint name, OPENGL_PRINTF_FORMAT const char* format, ...) { + GLchar label[256] = {}; + va_list args; + va_start(args, format); + const GLsizei length = vsnprintf(label, std::size(label), format, args); + va_end(args); + glObjectLabel(identifier, name, length, label); + } + struct VertexArray { GLuint m_handle = 0;