--- /dev/null
+/* $Id$
+
+This file is part of gldbg
+Copyright © 2009 Mikko Rasa, Mikkosoft Productions
+Distributed under the GPL
+*/
+
+#include <msp/strings/formatter.h>
+#include "bufferstate.h"
+#include "enums.h"
+
+using namespace std;
+using namespace Msp;
+
+BufferState::BufferState():
+ usage(GL_STATIC_DRAW),
+ size(0),
+ data(0)
+{ }
+
+void BufferState::set_data(unsigned sz, const void *ptr, GLenum use)
+{
+ usage = use;
+ size = sz;
+ delete[] data;
+ data = new char[size];
+ if(ptr)
+ set_sub_data(0, size, ptr);
+}
+
+void BufferState::set_sub_data(unsigned off, unsigned sz, const void *ptr)
+{
+ if(data && off+sz<size)
+ {
+ const char *cptr = reinterpret_cast<const char *>(ptr);
+ copy(cptr, cptr+sz, data+off);
+ }
+}
+
+string BufferState::describe() const
+{
+ return format("%d bytes, %s", size, describe_enum(usage, ""));
+}