X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbuffer.h;h=810bfc1a56253e181f7cc55b5d228c3441e99fee;hb=be6ffe96ecb4707599fe1a6f620c348760213d46;hp=df570d7eb01d2b8bae9f6115adfb2345435c4c53;hpb=acaefb4c669f01855252818ef0a2958cbdababc3;p=libs%2Fgl.git diff --git a/source/core/buffer.h b/source/core/buffer.h index df570d7e..810bfc1a 100644 --- a/source/core/buffer.h +++ b/source/core/buffer.h @@ -3,6 +3,7 @@ #include #include +#include "buffer_backend.h" namespace Msp { namespace GL { @@ -14,32 +15,22 @@ public: virtual ~buffer_too_small() throw() { } }; -class BufferRange; - /** A buffer for storing data in GL memory. Putting vertex and index data in buffers can improve rendering performance. The VertexArray, Mesh and UniformBlock classes contain built-in support for buffers. */ -class Buffer +class Buffer: public BufferBackend { - friend class PipelineState; - friend class Texture2D; - friend class VertexSetup; + friend BufferBackend; private: - unsigned id; - unsigned size; - - static Buffer *scratch_binding; + std::size_t size = 0; public: - Buffer(); - ~Buffer(); - /** Defines the storage size of the buffer. Must be called before data can be uploaded. Storage cannot be changed once set. */ - void storage(unsigned); + void storage(std::size_t); /** Uploads data into the buffer, completely replacing any previous contents. Storage must be defined beforehand. The data must have size @@ -48,21 +39,16 @@ public: /** Overwrites part of the buffer data with new data. Storage must be defined beforehand. */ - void sub_data(unsigned, unsigned, const void *); + void sub_data(std::size_t, std::size_t, const void *); - unsigned get_size() const { return size; } + std::size_t get_size() const { return size; } - void require_size(unsigned) const; + void require_size(std::size_t) const; - void *map(); - bool unmap(); + using BufferBackend::map; + using BufferBackend::unmap; - void set_debug_name(const std::string &); - -private: - void bind_scratch(); -public: - static void unbind_scratch(); + using BufferBackend::set_debug_name; }; } // namespace GL