IO::print("Buffer %d:\n", id);
IO::print(" Size: %d bytes\n", buf.size);
IO::print(" Usage: %s\n", describe_enum(buf.usage, ""));
- if(buf.content.stride)
+ if(buf.content.arrays.size()==1 && buf.content.arrays.front().kind==GL_ELEMENT_ARRAY_BUFFER)
+ {
+ const BufferContent::Array &array = buf.content.arrays.front();
+ IO::print(" Arrays:\n");
+ IO::print(" 0: Element indices, 1 %s\n", describe_enum(array.type, "DataType"));
+
+ IO::print(" Data:\n");
+ unsigned width = 1+buf.content.stride*2;
+ string fmt = format(" %%%du", width);
+ unsigned n_elems = buf.size/buf.content.stride;
+ string line;
+ const char *ptr = buf.data;
+ for(unsigned i=0; i<n_elems; ++i)
+ {
+ if(line.empty())
+ line = " ";
+
+ if(array.type==GL_UNSIGNED_BYTE)
+ line += format(fmt, *(reinterpret_cast<unsigned char *>(ptr)+i));
+ else if(array.type==GL_UNSIGNED_SHORT)
+ line += format(fmt, *(reinterpret_cast<unsigned short *>(ptr)+i));
+ else if(array.type==GL_UNSIGNED_INT)
+ line += format(fmt, *(reinterpret_cast<unsigned *>(ptr)+i));
+
+ if(line.size()+1+width>79)
+ {
+ IO::print("%s\n", line);
+ line.clear();
+ }
+ }
+
+ if(!line.empty())
+ IO::print("%s\n", line);
+ }
+ else if(buf.content.stride)
{
IO::print(" Stride: %d bytes\n", buf.content.stride);