From 1b45a71ff57a90ea913c6985121a64ba8e7d02c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 21:08:41 +0200 Subject: [PATCH] Allocation-free overloads for *::setLabel(). In most cases the label is set directly from code, e.g.: texture.setLabel("diffuse-duck"); Avoiding conversion to std::string and passing char(&)[size] directly will avoid one allocation and deallocation. Better solution would be to use std::string_view everywhere, but we're not in C++17 yet. --- src/Magnum/AbstractObject.cpp | 13 +++++++------ src/Magnum/AbstractObject.h | 9 +++++---- src/Magnum/AbstractShaderProgram.cpp | 2 +- src/Magnum/AbstractShaderProgram.h | 12 +++++++++++- src/Magnum/AbstractTexture.cpp | 2 +- src/Magnum/AbstractTexture.h | 13 ++++++++++++- src/Magnum/Buffer.cpp | 2 +- src/Magnum/Buffer.h | 11 ++++++++++- src/Magnum/BufferTexture.h | 4 ++++ src/Magnum/CubeMapTexture.h | 4 ++++ src/Magnum/CubeMapTextureArray.h | 4 ++++ src/Magnum/Framebuffer.cpp | 2 +- src/Magnum/Framebuffer.h | 11 ++++++++++- src/Magnum/Implementation/DebugState.h | 2 +- src/Magnum/Mesh.cpp | 2 +- src/Magnum/Mesh.h | 11 ++++++++++- src/Magnum/MultisampleTexture.h | 4 ++++ src/Magnum/Query.cpp | 2 +- src/Magnum/Query.h | 24 +++++++++++++++++++++++- src/Magnum/RectangleTexture.h | 4 ++++ src/Magnum/Renderbuffer.cpp | 2 +- src/Magnum/Renderbuffer.h | 13 ++++++++++++- src/Magnum/Shader.cpp | 2 +- src/Magnum/Shader.h | 12 +++++++++++- src/Magnum/Texture.h | 4 ++++ src/Magnum/TextureArray.h | 4 ++++ 26 files changed, 148 insertions(+), 27 deletions(-) diff --git a/src/Magnum/AbstractObject.cpp b/src/Magnum/AbstractObject.cpp index df921a0cf..0b07d3c8f 100644 --- a/src/Magnum/AbstractObject.cpp +++ b/src/Magnum/AbstractObject.cpp @@ -26,6 +26,7 @@ #include "AbstractObject.h" #include +#include #include "Magnum/Context.h" #include "Magnum/Extensions.h" @@ -123,26 +124,26 @@ Int AbstractObject::maxLabelLength() { return value; } -void AbstractObject::labelImplementationNoOp(GLenum, GLuint, const std::string&) {} +void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::ArrayReference) {} -void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const std::string& label) { +void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const Containers::ArrayReference label) { /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES - glObjectLabel(identifier, name, label.size(), label.data()); + glObjectLabel(identifier, name, label.size(), label); #else static_cast(identifier); static_cast(name); static_cast(label); CORRADE_INTERNAL_ASSERT(false); - //glObjectLabelKHR(identifier, name, label.size(), label.data()); + //glObjectLabelKHR(identifier, name, label.size(), label); #endif } -void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const std::string& label) { +void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayReference label) { const GLenum type = extTypeFromKhrIdentifier(identifier); /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES - glLabelObjectEXT(type, name, label.size(), label.data()); + glLabelObjectEXT(type, name, label.size(), label); #else static_cast(type); static_cast(name); diff --git a/src/Magnum/AbstractObject.h b/src/Magnum/AbstractObject.h index 54a220673..10cc5b821 100644 --- a/src/Magnum/AbstractObject.h +++ b/src/Magnum/AbstractObject.h @@ -30,9 +30,10 @@ */ #include +#include +#include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" -#include "Magnum/Types.h" #include "Magnum/visibility.h" namespace Magnum { @@ -66,9 +67,9 @@ class MAGNUM_EXPORT AbstractObject { MAGNUM_LOCAL ~AbstractObject() = default; private: - static MAGNUM_LOCAL void labelImplementationNoOp(GLenum, GLuint, const std::string&); - static MAGNUM_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, const std::string& label); - static MAGNUM_LOCAL void labelImplementationKhr(GLenum identifier, GLuint name, const std::string& label); + static MAGNUM_LOCAL void labelImplementationNoOp(GLenum, GLuint, Containers::ArrayReference label); + static MAGNUM_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, Containers::ArrayReference label); + static MAGNUM_LOCAL void labelImplementationKhr(GLenum identifier, GLuint name, Containers::ArrayReference label); static MAGNUM_LOCAL std::string getLabelImplementationNoOp(GLenum, GLuint); static MAGNUM_LOCAL std::string getLabelImplementationExt(GLenum identifier, GLuint name); static MAGNUM_LOCAL std::string getLabelImplementationKhr(GLenum identifier, GLuint name); diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index dabc8b881..4b836eacf 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -225,7 +225,7 @@ std::string AbstractShaderProgram::label() const { #endif } -AbstractShaderProgram& AbstractShaderProgram::setLabel(const std::string& label) { +AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_PROGRAM, _id, label); #else diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 9da0dc74f..eb1888de3 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -31,6 +31,7 @@ #include #include +#include #include #include "Magnum/AbstractObject.h" @@ -540,7 +541,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @def_gl{PROGRAM} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{PROGRAM_OBJECT_EXT} */ - AbstractShaderProgram& setLabel(const std::string& label); + AbstractShaderProgram& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractShaderProgram& setLabel(const char (&label)[size]) { + return setLabelInternal(label); + } /** * @brief Validate program @@ -817,6 +825,8 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { #endif private: + AbstractShaderProgram& setLabelInternal(Containers::ArrayReference label); + #ifndef MAGNUM_BUILD_DEPRECATED void use(); #endif diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 61e3c870f..756940c2b 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -189,7 +189,7 @@ std::string AbstractTexture::label() const { return Context::current()->state().debug->getLabelImplementation(GL_TEXTURE, _id); } -AbstractTexture& AbstractTexture::setLabel(const std::string& label) { +AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayReference label) { Context::current()->state().debug->labelImplementation(GL_TEXTURE, _id, label); return *this; } diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 56c8164c5..6d713509a 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -29,6 +29,8 @@ * @brief Class @ref Magnum::AbstractTexture */ +#include + #include "Magnum/Sampler.h" #include "Magnum/AbstractObject.h" @@ -258,7 +260,14 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{TEXTURE} */ - AbstractTexture& setLabel(const std::string& label); + AbstractTexture& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractTexture& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** @brief OpenGL texture ID */ GLuint id() const { return _id; } @@ -288,6 +297,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { explicit AbstractTexture(GLenum target); + AbstractTexture& setLabelInternal(Containers::ArrayReference label); + /* Unlike bind() this also sets the texture binding unit as active */ void MAGNUM_LOCAL bindInternal(); diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 37d96f8fc..75411ae09 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -138,7 +138,7 @@ std::string Buffer::label() const { #endif } -Buffer& Buffer::setLabel(const std::string& label) { +Buffer& Buffer::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_BUFFER, _id, label); #else diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index cc9d24d13..e53d24fd5 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -582,7 +582,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * or @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{BUFFER_OBJECT_EXT} */ - Buffer& setLabel(const std::string& label); + Buffer& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Buffer& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** @brief Target hint */ Target targetHint() const { return _targetHint; } @@ -854,6 +861,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif private: + Buffer& setLabelInternal(Containers::ArrayReference label); + static void bind(Target hint, GLuint id); Target MAGNUM_LOCAL bindInternal(Target hint); diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index 980aae547..cf8fabf80 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -269,6 +269,10 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template BufferTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif private: diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 087c3e1ae..67319620b 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -382,6 +382,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template CubeMapTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index 22230f084..e067c98b9 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -405,6 +405,10 @@ class CubeMapTextureArray: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template CubeMapTextureArray& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index cf028c4de..9aafd0cce 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -112,7 +112,7 @@ std::string Framebuffer::label() const { return Context::current()->state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id); } -Framebuffer& Framebuffer::setLabel(const std::string& label) { +Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayReference label) { Context::current()->state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); return *this; } diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 79d75d125..2368e938c 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -354,7 +354,14 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{FRAMEBUFFER} */ - Framebuffer& setLabel(const std::string& label); + Framebuffer& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Framebuffer& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Check framebuffer status @@ -627,6 +634,8 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje #endif private: + Framebuffer& setLabelInternal(Containers::ArrayReference label); + void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer); diff --git a/src/Magnum/Implementation/DebugState.h b/src/Magnum/Implementation/DebugState.h index a435e1b20..dd90ec181 100644 --- a/src/Magnum/Implementation/DebugState.h +++ b/src/Magnum/Implementation/DebugState.h @@ -36,7 +36,7 @@ struct DebugState { explicit DebugState(Context& context, std::vector& extensions); std::string(*getLabelImplementation)(GLenum, GLuint); - void(*labelImplementation)(GLenum, GLuint, const std::string&); + void(*labelImplementation)(GLenum, GLuint, Containers::ArrayReference); void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, const std::string&); void(*messageCallbackImplementation)(DebugMessage::Callback, const void*); diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index c91a8059f..54ab76406 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -148,7 +148,7 @@ std::string Mesh::label() const { #endif } -Mesh& Mesh::setLabel(const std::string& label) { +Mesh& Mesh::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label); #else diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index c2d40b3fb..4e3cdf063 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -467,7 +467,14 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @def_gl{VERTEX_ARRAY} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{VERTEX_ARRAY_OBJECT_EXT} */ - Mesh& setLabel(const std::string& label); + Mesh& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Mesh& setLabelInternal(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Whether the mesh is indexed @@ -836,6 +843,8 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { #endif #endif + Mesh& setLabelInternal(Containers::ArrayReference label); + /* Computing stride of interleaved vertex attributes */ template static GLsizei strideOfInterleaved(const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { return attribute.vectorSize()*AbstractShaderProgram::Attribute::VectorCount + strideOfInterleaved(attributes...); diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index 54c4e1038..6bc3848e4 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -180,6 +180,10 @@ template class MultisampleTexture: public AbstractTextur AbstractTexture::setLabel(label); return *this; } + template MultisampleTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/Query.cpp b/src/Magnum/Query.cpp index d6bee60f2..8fd4e7a15 100644 --- a/src/Magnum/Query.cpp +++ b/src/Magnum/Query.cpp @@ -66,7 +66,7 @@ std::string AbstractQuery::label() const { #endif } -AbstractQuery& AbstractQuery::setLabel(const std::string& label) { +AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_QUERY, _id, label); #else diff --git a/src/Magnum/Query.h b/src/Magnum/Query.h index 99c62c641..a0b152c4f 100644 --- a/src/Magnum/Query.h +++ b/src/Magnum/Query.h @@ -29,6 +29,7 @@ * @brief Class @ref Magnum::AbstractQuery, @ref Magnum::PrimitiveQuery, @ref Magnum::SampleQuery, @ref Magnum::TimeQuery */ +#include #include #include "Magnum/AbstractObject.h" @@ -84,7 +85,14 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { * @def_gl{QUERY} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{QUERY_OBJECT_EXT} */ - AbstractQuery& setLabel(const std::string& label); + AbstractQuery& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractQuery& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Whether the result is available @@ -140,6 +148,8 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { void begin(GLenum target); private: + AbstractQuery& setLabelInternal(Containers::ArrayReference label); + GLuint _id; GLenum target; }; @@ -217,6 +227,10 @@ class PrimitiveQuery: public AbstractQuery { AbstractQuery::setLabel(label); return *this; } + template PrimitiveQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } #endif }; #endif @@ -367,6 +381,10 @@ class SampleQuery: public AbstractQuery { AbstractQuery::setLabel(label); return *this; } + template SampleQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } #endif }; @@ -446,6 +464,10 @@ class TimeQuery: public AbstractQuery { AbstractQuery::setLabel(label); return *this; } + template TimeQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 3bea9918d..cf98b51e9 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -404,6 +404,10 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template RectangleTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/Renderbuffer.cpp b/src/Magnum/Renderbuffer.cpp index 47a99b4bb..d2a0e8b4e 100644 --- a/src/Magnum/Renderbuffer.cpp +++ b/src/Magnum/Renderbuffer.cpp @@ -81,7 +81,7 @@ std::string Renderbuffer::label() const { return Context::current()->state().debug->getLabelImplementation(GL_RENDERBUFFER, _id); } -Renderbuffer& Renderbuffer::setLabel(const std::string& label) { +Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayReference label) { Context::current()->state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); return *this; } diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index 33b82bf11..c5bfe4b4f 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -29,6 +29,8 @@ * @brief Class @ref Magnum::Renderbuffer */ +#include + #include "Magnum/AbstractObject.h" #include "Magnum/Magnum.h" @@ -135,7 +137,14 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { * @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{RENDERBUFFER} */ - Renderbuffer& setLabel(const std::string& label); + Renderbuffer& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Renderbuffer& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Set renderbuffer storage @@ -169,6 +178,8 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size); private: + Renderbuffer& setLabelInternal(Containers::ArrayReference label); + void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size); diff --git a/src/Magnum/Shader.cpp b/src/Magnum/Shader.cpp index 86d4b8722..1d3f3d31b 100644 --- a/src/Magnum/Shader.cpp +++ b/src/Magnum/Shader.cpp @@ -580,7 +580,7 @@ std::string Shader::label() const { #endif } -Shader& Shader::setLabel(const std::string& label) { +Shader& Shader::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_SHADER, _id, label); #else diff --git a/src/Magnum/Shader.h b/src/Magnum/Shader.h index 1afd37c31..adab40a4b 100644 --- a/src/Magnum/Shader.h +++ b/src/Magnum/Shader.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "Magnum/AbstractObject.h" #include "Magnum/Magnum.h" @@ -504,7 +505,14 @@ class MAGNUM_EXPORT Shader: public AbstractObject { * @def_gl{SHADER} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{SHADER_OBJECT_EXT} */ - Shader& setLabel(const std::string& label); + Shader& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Shader& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** @brief %Shader type */ Type type() const { return _type; } @@ -545,6 +553,8 @@ class MAGNUM_EXPORT Shader: public AbstractObject { bool compile() { return compile({*this}); } private: + Shader& setLabelInternal(Containers::ArrayReference label); + Type _type; GLuint _id; diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 6aa1bdbe8..25a142b99 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -759,6 +759,10 @@ template class Texture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template Texture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 37916c8d7..78630806d 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -389,6 +389,10 @@ template class TextureArray: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template TextureArray& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif };