]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/rendertarget.cpp
Add debug name capability to more classes
[libs/gl.git] / source / render / rendertarget.cpp
index 5c4cc20ffdcbd05c477eacde748fb2a8a3170c8a..7b603252b6e1c97f0b80ad953734147e6c8efcc2 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/core/maputils.h>
+#include <msp/strings/format.h>
 #include "error.h"
 #include "renderbuffer.h"
 #include "rendertarget.h"
@@ -202,5 +203,30 @@ void RenderTarget::blit_from(const RenderTarget &other)
        fbo.blit_from(other.fbo, COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT, false);
 }
 
+void RenderTarget::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+       fbo.set_debug_name(name+" [FBO]");
+       unsigned i = 0;
+       for(const unsigned char *j=format.begin(); j!=format.end(); ++i, ++j)
+       {
+               unsigned type = get_output_type(*j);
+
+               string buf_name;
+               if(type>=get_output_type(RENDER_DEPTH))
+                       buf_name = name+"/depth";
+               else
+                       buf_name = Msp::format("%s/color%d", name, type);
+
+               if(samples)
+                       buffers[i].buffer->set_debug_name(buf_name+".tex2d");
+               else
+                       buffers[i].texture->set_debug_name(buf_name+".rbuf");
+       }
+#else
+       (void)name;
+#endif
+}
+
 } // namespace GL
 } // namespace Msp