X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuffer.h;h=d8a8419c0211fbc9b70429a95bcb7cc7c5065145;hb=196093790e242dec24bfbbf7ad8c28dcc442824c;hp=7aea9665d8dd9a2ddaf77695891aa7c840a0810c;hpb=85c82f93f4874bcf0b04332c9abb62cd2a5b181b;p=libs%2Fgl.git diff --git a/source/buffer.h b/source/buffer.h index 7aea9665..d8a8419c 100644 --- a/source/buffer.h +++ b/source/buffer.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GL_BUFFER_H_ #define MSP_GL_BUFFER_H_ @@ -45,6 +38,7 @@ private: BufferType type; BufferUsage usage; unsigned id; + unsigned size; static const Buffer *bound[4]; @@ -68,6 +62,8 @@ public: not be changed with this call. */ void sub_data(unsigned, unsigned, const void *); + unsigned get_size() const { return size; } + /** Binds the buffer in its default slot. */ void bind() const { bind_to(type); } @@ -84,6 +80,23 @@ private: static void restore(const Buffer *, BufferType); }; +/** +An adaptor for Buffer to make it compatible with Bind. +*/ +template +class BufferAlias +{ +private: + const Buffer &buffer; + +public: + BufferAlias(const Buffer &b): buffer(b) { } + + void bind() const { buffer.bind_to(T); } + static const Buffer *current() { return Buffer::current(T); } + static void unbind() { Buffer::unbind_from(T); } +}; + } // namespace GL } // namespace Msp