]> git.tdb.fi Git - libs/gl.git/blobdiff - source/buffer.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / buffer.cpp
diff --git a/source/buffer.cpp b/source/buffer.cpp
deleted file mode 100644 (file)
index 395057c..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "arb_vertex_buffer_object.h"
-#include "extension.h"
-#include "buffer.h"
-
-namespace Msp {
-namespace GL {
-
-Buffer::Buffer(BufferType t):
-       type(t),
-       usage(STATIC_DRAW)
-{
-       static RequireExtension _req_vbo("GL_ARB_vertex_buffer_object");
-       if(type==PIXEL_PACK_BUFFER || type==PIXEL_UNPACK_BUFFER)
-               static RequireExtension _req_pbo("GL_ARB_pixel_buffer_object");
-
-       glGenBuffersARB(1, &id);
-}
-
-Buffer::~Buffer()
-{
-       glDeleteBuffersARB(1, &id);
-}
-
-void Buffer::set_usage(BufferUsage u)
-{
-       usage = u;
-}
-
-void Buffer::data(unsigned size, const void *d)
-{
-       const Buffer *old = current(type);
-       bind();
-       glBufferDataARB(type, size, d, usage);
-       restore(old, type);
-}
-
-void Buffer::sub_data(unsigned offset, unsigned size, const void *d)
-{
-       const Buffer *old = current(type);
-       bind();
-       glBufferSubDataARB(type, offset, size, d);
-       restore(old, type);
-}
-
-void Buffer::bind_to(BufferType t) const
-{
-       const Buffer *&ptr = binding(t);
-       if(ptr!=this)
-       {
-               glBindBufferARB(t, id);
-               ptr = this;
-       }
-}
-
-void Buffer::unbind_from(BufferType type)
-{
-       const Buffer *&ptr = binding(type);
-       if(ptr)
-       {
-               glBindBufferARB(type, 0);
-               ptr = 0;
-       }
-}
-
-const Buffer *&Buffer::binding(BufferType type)
-{
-       switch(type)
-       {
-       case ARRAY_BUFFER:         return bound[0];
-       case ELEMENT_ARRAY_BUFFER: return bound[1];
-       case PIXEL_PACK_BUFFER:    return bound[2];
-       case PIXEL_UNPACK_BUFFER:  return bound[3];
-       default: throw InvalidParameterValue("Invalid buffer type");
-       }
-}
-
-void Buffer::restore(const Buffer *buf, BufferType type)
-{
-       if(buf!=current(type))
-       {
-               if(buf)
-                       buf->bind_to(type);
-               else
-                       unbind_from(type);
-       }
-}
-
-const Buffer *Buffer::bound[4] = { 0, 0, 0, 0 };
-
-} // namespace GL
-} // namespace Msp