- 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)
+ printf("Buffer %d:\n", id);
+ printf(" Size: %d bytes\n", buf.size);
+ printf(" Usage: %s\n", describe_enum(buf.usage, ""));
+ if(buf.content.arrays.size()==1 && buf.content.arrays.front().kind==GL_ELEMENT_ARRAY_BUFFER)
+ {
+ const BufferContent::Array &array = buf.content.arrays.front();
+ printf(" Arrays:\n");
+ printf(" 0: Element indices, 1 %s\n", describe_enum(array.type, "DataType"));
+
+ printf(" Data:\n");
+ unsigned width = 1+buf.content.stride*2;
+ char fmt[6];
+ snprintf(fmt, sizeof(fmt), " %%%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 += strformat(fmt, *(reinterpret_cast<const unsigned char *>(ptr)+i));
+ else if(array.type==GL_UNSIGNED_SHORT)
+ line += strformat(fmt, *(reinterpret_cast<const unsigned short *>(ptr)+i));
+ else if(array.type==GL_UNSIGNED_INT)
+ line += strformat(fmt, *(reinterpret_cast<const unsigned *>(ptr)+i));
+
+ if(line.size()+1+width>79)
+ {
+ printf("%s\n", line.c_str());
+ line.clear();
+ }
+ }
+
+ if(!line.empty())
+ printf("%s\n", line.c_str());
+ }
+ else if(buf.content.stride)