*/
#include <msp/strings/formatter.h>
+#include "arraysize.h"
#include "arraystate.h"
#include "bufferstate.h"
#include "enums.h"
arrays.insert(place, array);
}
+void BufferContent::update_elements(GLenum type)
+{
+ if(arrays.empty())
+ {
+ Array array;
+ array.kind = GL_ELEMENT_ARRAY_BUFFER;
+ array.type = type;
+ arrays.push_back(array);
+ stride = typesize(type);
+ }
+ else if(arrays.size()>1 || arrays.front().kind!=GL_ELEMENT_ARRAY_BUFFER)
+ consistent = false;
+ else
+ {
+ if(arrays.front().type!=type)
+ consistent = false;
+ arrays.front().type = type;
+ stride = typesize(type);
+ }
+}
+
string BufferContent::describe() const
{
if(arrays.empty())
kind = 'C';
else if(i->kind==GL_TEXTURE_COORD_ARRAY && i->index==0)
kind = 'T';
+ else if(i->kind==GL_ELEMENT_ARRAY_BUFFER)
+ kind = 'E';
char type[3] = { '?', 0, 0 };
if(i->type==GL_FLOAT)
}
+BufferContent::Array::Array():
+ kind(GL_NONE),
+ index(0),
+ size(1),
+ type(GL_NONE),
+ offset(0)
+{ }
+
BufferContent::Array::Array(const ArrayState &a):
kind(a.kind),
index(a.index),
BufferState::BufferState():
+ id(0),
+ target(0),
usage(GL_STATIC_DRAW),
size(0),
data(0)
string BufferState::describe() const
{
if(content.stride)
- return format("%s, %d vertices (%d bytes), %s",
- content.describe(), size/content.stride, size, describe_enum(usage, ""));
+ {
+ const char *what = (content.arrays.front().kind==GL_ELEMENT_ARRAY_BUFFER ? "indices" : "vertices");
+ return format("%s, %d %s (%d bytes), %s",
+ content.describe(), size/content.stride, what, size, describe_enum(usage, ""));
+ }
else
return format("%d bytes, %s", size, describe_enum(usage, ""));
}