X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbuffer.h;h=810bfc1a56253e181f7cc55b5d228c3441e99fee;hb=be6ffe96ecb4707599fe1a6f620c348760213d46;hp=0fb2cde18d68f9ca29859d6db578396ff7e5d125;hpb=b09f265880a3a932441091b0f3822b06c112c595;p=libs%2Fgl.git diff --git a/source/core/buffer.h b/source/core/buffer.h index 0fb2cde1..810bfc1a 100644 --- a/source/core/buffer.h +++ b/source/core/buffer.h @@ -3,8 +3,7 @@ #include #include -#include -#include "gl.h" +#include "buffer_backend.h" namespace Msp { namespace GL { @@ -16,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 @@ -50,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